// Starcraft 2 enjoyer //
#include <bits/stdc++.h>
// #pragma GCC target("avx2")
// #pragma GCC optimize("O3")
// #pragma GCC optimize("unroll-loops")
using namespace std;
#define LSOne(X) ((X) & -(X))
#define int long long
const int N = 1e5 + 5;
const int M = 1e6 + 5;
const int K = 1e3 + 5;
const int LG = 60;
const int INF = 1e18 + 5;
const int B = 1000;
const int MOD = 1e9 + 7;
int n;
double a[N], b[N], pa[N], pb[N], res;
inline void solve()
{
cin >> n;
for (int x = 0; x < n; x++)
{
cin >> a[x] >> b[x];
a[x]--;
b[x]--;
}
sort(a, a + n);
reverse(a, a + n);
sort(b, b + n);
reverse(b, b + n);
pa[0] = a[0];
pb[0] = b[0];
res = 0;
for (int x = 1; x < n; x++)
{
pa[x] = pa[x - 1] + a[x];
pb[x] = pb[x - 1] + b[x];
}
for (int x = 1; x <= n; x++)
{
int l = 1, r = n - 1, ans = 0;
while (l <= r)
{
int m = (l + r) / 2;
if (pa[x - 1] - (m + 1) >= pb[m] - x)
{
ans = m;
l = m + 1;
}
else
{
r = m - 1;
}
}
res = max(res, min(pa[x - 1] - (ans + 1), pb[ans] - x));
ans++;
if (ans < n)
{
res = max(res, min(pa[x - 1] - (ans + 1), pb[ans] - x));
}
}
cout << fixed << setprecision(4) << res;
}
signed main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int t = 1;
// cin >> t;
for (int x = 1; x <= t; x++)
{
solve();
}
return 0;
}