#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
int n;
cin >> n;
vector<double> a(n), b(n);
for (int i = 0; i < n; i++) {
cin >> a[i] >> b[i];
}
sort(a.rbegin(), a.rend());
sort(b.rbegin(), b.rend());
vector<double> pa(n + 1);
vector<double> pb(n + 1);
for (int i = 0; i <= n; i++) {
pa[i] = 0.0;
}
for (int i = 0; i <= n; i++) {
pb[i] = 0.0;
}
for (int i = 1; i <= n; i++) {
pa[i] = pa[i - 1] + a[i - 1];
pb[i] = pb[i - 1] + b[i - 1];
}
double ans = 0.0;
for (double i = 0; i <= n; i++) {
for (double j = 0; j <= n; j++) {
double x = i + j;
double d1 = pa[i] - x;
double d2 = pb[j] - x;
ans = max(ans, min(d1, d2));
}
}
cout << fixed << setprecision(9) << ans;
return 0;
}