#include<bits/stdc++.h>
using namespace std;
#define fast                         ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define int                          long long int
#define double                       long double
#define ff                           first
#define ss                           second
#define pb                           push_back
#define eb                           emplace_back
#define all(x)                       (x).begin(), (x).end()
#define sz(x)                        ((int)(x).size())
#define len(x)                       ((int)(x).length())
#define pii                          pair<int,int>
#define vi                            vector<int>
#define vd                           vector<double>
#define vs                            vector<string>
#define mp                          map<int,int>
#define ms(x,y)                     memset(x,y,sizeof(x))
#define ump                         unordered_map<int,int>
 
#define lb                            lower_bound
#define ub                            upper_bound
#define nx                            cout<<"\n";
#define inf                           9223372036854775807
#define PI                            3.14159265
 
const int MOD = 1e9 + 7;
 
inline int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
inline int lcm(int a, int b) { return a * b / gcd(a, b); }
inline int add(int a, int b) {    return ((a % MOD) + (b % MOD)) % MOD;}
 
inline int multi(int a, int b) {   return ((a % MOD) * (b % MOD)) % MOD;}
 
inline int sub(int a, int b) {       a %= MOD; b %= MOD; a -= b; if (a < 0) a += MOD; return a;}
 
inline int power(int a, int b) {       a %= MOD; int res = 1; while (b > 0) {if (b & 1) {res = multi(res, a);} a = multi(a, a); b >>= 1;}  return res;}
 
bool isPrime(int  x) {      if (x <= 4 || x % 2 == 0 || x % 3 == 0) {return x == 2 || x == 3;} for (int i = 5; i * i <= x; i += 6) {if (x % i == 0 || x % (i + 2) == 0) { return 0;}} return 1;}
 

 
 
int32_t main()
{
	fast ;

	int n; cin>>n;
	int arr[n];
	int sum = 0;
	for(int i=0;i<n;i++){
		int a,b; cin>>a>>b;
		arr[i] = 2*a + b;
		sum+=a;
	}
	sort(arr,arr+n);
	int cnt = 0;
	int i = n-1;
	while(sum>=0){
		sum-=arr[i];
		i--;
		cnt++;
	}
	cout<<cnt<<endl;
	
}

// C++(GCC 9.2.1)
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
#define repex(i, a, b, c) for(int i = a; i < b; i += c)
#define repx(i, a, b) repex(i, a, b, 1)
#define rep(i, n) repx(i, 0, n)
#define repr(i, a, b) for(int i = a; i >= b; i--)
LL a[101010], aCum[101010];

int main(){
    
    // 1. 入力情報.
    int N;
    scanf("%d", &N);
    rep(i, N){
        scanf("%lld", &a[i]);
        a[i] *= 2;
    }
    
    // 2. sort.
    sort(a, a + N);
    
    // 3. 累積和.
    rep(i, N) aCum[i + 1] = aCum[i] + a[i];
    
    // 4. 期待値の最小化を計算.
    LL t = 202020202020202020;
    rep(i, N){
        LL x = a[i] / 2;
        LL l = N * x + aCum[N] - (N - i) * a[i] - aCum[i];
        t = min(t, l);
    }
    
    // 5. 出力.
    double ans = (double)t / (double)(N * 2.0);
    printf("%.12lf\n", ans);
    return 0;
    
}