#include<bits/stdc++.h>
using namespace std;

//#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")


#define pb push_back
#define fi first
#define se second
#define ll long long
#define tp top()
#define fr front()
#define vi vector<int>
#define sz size()
#define rep(i,a,b) for(int i = a; i < b; ++i)
#define mem(a,  b) memset(a,  (b),  sizeof(a))
#define clr(a) memset(a,  0,  sizeof(a))
#define sqr(x) ( (x) * (x) )
#define all(v) v.begin(),  v.end()

typedef pair<int, int> pii;
typedef pair<int,pii> pip;
typedef pair<pii,int> ppi;
typedef pair<pii,pii> ppp;



void base(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}

void solve(){
	int n;
	cin>>n;
	priority_queue<pair<ll, pair<ll,ll>>> pq;
	ll suma=0;
	rep(i,0,n){
		ll a,b;
		cin>>a>>b;
		suma+=a;
		pq.push({2*a+b,{a,b}});
	}
	ll sumb=0;
	int cnt=0;
	while(pq.sz){
		sumb += pq.tp.se.fi + pq.tp.se.se;
		suma -= pq.tp.se.fi;
		cnt++;
		pq.pop();
//		cerr<<cnt<<" "<<suma<<" "<<sumb<<"|n";
		if (sumb > suma) break;
	}
	cout<<cnt<<"\n";
}

int main()
{
	base();
//  freopen("input.txt", "r", stdin);
//  freopen("output.txt", "w", stdout);
	int t=1;
//	cin>>t;
	while(t--){
		solve();
	}
	return 0;
}





#include <cstdio>
#include <cstring>

typedef long long ll;
const int N=300005;

int n,a[N];
ll res;
struct BIT
{
    int tr[N],r;
    void add(int x){for(++x;x<=n;x+=x&-x)tr[x]++;}
    int ask(int x){r=0;for(++x;x;x&=x-1)r+=tr[x];return r;}
}fw;

int main()
{
    scanf("%d",&n);
    for(int i=0;i<n;i++)
    {
        scanf("%d",a+i);
        res+=i-fw.ask(a[i]);
        fw.add(a[i]);
    }
    for(int i=0;i<n;i++)
    {
        printf("%lld\n",res);
        res+=n-a[i]*2-1;
    }
    return 0;
}
