#include <bits/stdc++.h>
using namespace std;
priority_queue<double> a, b;
double ca, cb, ans;
void cha() {
ca += a.top()-1;
cb -= 1;
a.pop();
}
void chb() {
cb += b.top()-1;
ca -= 1;
b.pop();
}
int main() {
int n;
cin >> n;
for(int i=1; i<=n; i++) {
double x, y;
cin >> x >> y;
a.push(x);
b.push(y);
}
while(!a.empty() || !b.empty()) {
if(a.empty()) chb();
else if(b.empty()) cha();
else if(ca == cb) {
if(a.top() > b.top()) cha();
else chb();
} else if(ca > cb) chb();
else cha();
ans = max(ans, min(ca, cb));
}
cout << fixed << setprecision(4) << ans;
}