stablegradients/pie-gem5-pairs huggingface dataset:
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;



int n, a[100001];

long long sum[100001];

int main() {

	cin >> n;

	for(int i = 1; i <= n; i++) cin >> a[i];

	sort(a+1, a+n+1);

	for(int i = 1; i <= n; i++) sum[i] = sum[i-1] + a[i];

	for(int i = n-1; i >= 0; i--) {

		if(a[i+1] > 2*sum[i]) {

			cout << n-i;

			return 0;

		}

	}

}


// Faster C++ solution for the same problem (measured speedup: 4.827468549569513x):
#include<stdio.h>

#include<algorithm>

using namespace std;

int main()

{

	int n,a[100005],i,ans;

	unsigned long long sum;

	scanf("%d",&n);

	for(i=0;i<n;i++)

	scanf("%d",&a[i]);

	sort(a,a+n);

	sum=0;

	ans=0;

	for(i=0;i<n;i++)

	{

		if(a[i]<=2*sum)

		{

			sum+=a[i];

			ans++;

		}

		else

		{

			sum+=a[i];

			ans=1;

		}

	}

	printf("%d\n",ans);

	return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>

#define rank tipa_rank

#define pb push_back

#define mp make_pair

#define ll long long

#define ull unsigned long long

#define INF 1000000000

#define EPS 1e-6

#define EPS2 1e-8

using namespace std;

const ll MOD = INF + 7;

using namespace std;

int ans;

int n;

int a[100000];

bool good(int x)

{

	ll sz = 0;

	for(int i = 0; i <= x; i++)

	{

		sz += a[i];

	}

	bool good = true;

	for(int i = x + 1; i < n; i++)

	{

		if(a[i] <= 2 * sz)

		{

			sz += a[i];

		}

		else

		{

			good = false;

			break;

		}

	}

	return good;

}

int main()

{

	scanf("%d" , &n);

	for(int i = 0; i < n; i++)

		scanf("%d" , &a[i]);

	sort(a , a + n);

	int l = 0 , r = n - 1;

	while(abs(r - l) > 1)

	{

		int m = (l + r) / 2;

		if(good(m))

		{

			r = m;

		}

		else

		{

			l = m + 1;

		}

	}

	if(l > r)

	{

		swap(l , r);

	}

	if(good(l))

	{

		cout << n - l;

	}

	else

		cout << n - r;

}


// Faster C++ solution for the same problem (measured speedup: 4.787424830179808x):
#include<stdio.h>

#include<algorithm>

using namespace std;

int main()

{

	int n,a[100005],i,ans;

	unsigned long long sum;

	scanf("%d",&n);

	for(i=0;i<n;i++)

	scanf("%d",&a[i]);

	sort(a,a+n);

	sum=0;

	ans=0;

	for(i=0;i<n;i++)

	{

		if(a[i]<=2*sum)

		{

			sum+=a[i];

			ans++;

		}

		else

		{

			sum+=a[i];

			ans=1;

		}

	}

	printf("%d\n",ans);

	return 0;

}
// Slower C++ solution:
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>

#include <sstream>

#include <iomanip>

#include <cstdio>

#include <cstdlib>

#include <cmath>

#include <cctype>

#include <cstring>

#include <vector>

#include <list>

#include <queue>

#include <deque>

#include <stack>

#include <map>

#include <set>

#include <algorithm>

#include <iterator>

#include <bitset>

#include <ctime>

#include<complex>

using namespace std;



#define FOR(i,a,b) for (int i = (a); i < (b); i++)

#define RFOR(i,b,a) for (int i = (b)-1; i >= (a); i--)

#define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)

#define FILL(a,value) memset(a, value, sizeof(a))



#define SZ(a) (int)a.size()

#define ALL(a) a.begin(), a.end()

#define PB push_back

#define MP make_pair



typedef long long LL;

typedef vector<int> VI;

typedef pair<int, int> PII;



const double PI = acos(-1.0);

const int INF = 1000 * 1000 * 1000 + 7;

const LL LINF = INF * (LL)INF;



const int MAX = 100000 + 47;

const int MOD = 1000 * 1000 * 1000 + 7;



int A[MAX];

LL P[MAX];



int main()

{

	//freopen("in.txt", "r", stdin);

	//freopen("out.txt", "w", stdout);

	ios::sync_with_stdio(false); cin.tie(0);

	int n;

	cin >> n;

	LL s = 0;

	FOR(i, 0, n)

	{

		cin >> A[i];

	}



	sort(A, A + n);

	FOR(i, 0, n)

	{

		P[i] = A[i];

		if (i) P[i] += P[i - 1];

	}



	int ind = -1;

	RFOR(i, n - 1, 0)

	{

		if (P[i] * 2 < A[i + 1])

		{

			ind = i;

			break;

		}

	}



	cout << n - ind - 1 << endl;

}

// Faster C++ solution for the same problem (measured speedup: 4.893714040599434x):
#include<stdio.h>

#include<algorithm>

using namespace std;

int main()

{

	int n,a[100005],i,ans;

	unsigned long long sum;

	scanf("%d",&n);

	for(i=0;i<n;i++)

	scanf("%d",&a[i]);

	sort(a,a+n);

	sum=0;

	ans=0;

	for(i=0;i<n;i++)

	{

		if(a[i]<=2*sum)

		{

			sum+=a[i];

			ans++;

		}

		else

		{

			sum+=a[i];

			ans=1;

		}

	}

	printf("%d\n",ans);

	return 0;

}
// Slower C++ solution:
# include <bits/stdc++.h>



# define pb push_back

# define fr first

# define sc second

# define mk make_pair



using namespace std;



const int inf = 1000000000 + 7;

const int N = 1e6 + 5;



typedef long long ll;



ll n, a[N], pref[N], ans;



inline void solve()

{

    cin >> n;



    for(int i = 1; i <= n; i ++)

        cin >> a[i];



    sort(a + 1, a + n + 1);



    for(int i = 1; i <= n; i ++)

        pref[i] = a[i] + pref[i - 1];

    for(int i = n; i >= 1; i --)

    {

        if(pref[i] * 2 >= a[i + 1])

            ans ++;

        else

            break;

    }



    cout << ans << endl;

}



int tests = 1;



int main()

{

//    scanf("%d", &tests);



    while(tests --)

        solve();

}


// Faster C++ solution for the same problem (measured speedup: 5.21374045639478x):
#include <cstdio>

#include <algorithm>

using namespace std;

const int MAXN=110000;

int n, a[MAXN];

bool check(int k)

{

	long long s=0;

	for (int i=1; i<=k; i++) s+=a[i];

	for (int i=k+1; i<=n; i++)

	{

		if (2*s<a[i]) return 0;

		s+=a[i];

	}

	return 1;

}

int main()

{

//	freopen("B.in", "r", stdin);

//	freopen("B.out", "w", stdout);

	scanf("%d", &n);

	for (int i=1; i<=n; i++) scanf("%d", &a[i]);

	sort(a+1, a+n+1);

	int l=1, r=n;

	while (l<r)

	{

		int mid=l+r>>1;

		if (check(mid)) r=mid;

		else l=mid+1;

	}

	printf("%d\n", n-l+1);

	return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>



#define fr first

#define sc second

#define mk make_pair

#define pb push_back

#define ll long long

#define OK puts("OK");

#define sz(s) (int)s.size()

#define all(s) s.begin(), s.end()



using namespace std;



const int N = 1e5 + 10;

const int inf = 1e9 + 7;





int a[N], ans, n;

ll s;



main()

{

    scanf("%d", &n);

    for(int i = 1; i <= n; i++)

        scanf("%d", a + i);

    sort(a + 1, a + n + 1);

    ans = n;

    for(int i = 1 ; i < n ; i ++)

    {

        s += a[i];

        if(s * 2 < a[i + 1])

            ans = n - i;

    }

    cout << ans << endl;





}








// Faster C++ solution for the same problem (measured speedup: 5.216559528000949x):
#include <cstdio>

#include <algorithm>

using namespace std;

const int MAXN=110000;

int n, a[MAXN];

bool check(int k)

{

	long long s=0;

	for (int i=1; i<=k; i++) s+=a[i];

	for (int i=k+1; i<=n; i++)

	{

		if (2*s<a[i]) return 0;

		s+=a[i];

	}

	return 1;

}

int main()

{

//	freopen("B.in", "r", stdin);

//	freopen("B.out", "w", stdout);

	scanf("%d", &n);

	for (int i=1; i<=n; i++) scanf("%d", &a[i]);

	sort(a+1, a+n+1);

	int l=1, r=n;

	while (l<r)

	{

		int mid=l+r>>1;

		if (check(mid)) r=mid;

		else l=mid+1;

	}

	printf("%d\n", n-l+1);

	return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>



#define pb push_back

#define mk make_pair

#define sc second

#define fr first



using namespace std;



typedef long long ll;



const long long N = (long long) 1e6 + 5;

const long long mod = (long long) 1e9 + 7;



long long n,a[N],ans = 1,pr[N],dp[N];



int main(){

        cin >> n;



        for(long long i = 1; i <= n; i ++)

                cin >> a[i];



        sort(a + 1,a + n + 1);



        for(long long i = 1; i <= n; i ++)

                pr[i] = pr[i - 1] + a[i];



        dp[n] = 1;

        for(long long i = n - 1; i >= 1; i --){

                if(a[i + 1] <= pr[i] * 2 && dp[i + 1] == 1)

                        dp[i] = 1,ans ++;

        }

        cout << ans << endl;

        return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.214529232052775x):
#include <cstdio>

#include <algorithm>

using namespace std;

const int MAXN=110000;

int n, a[MAXN];

bool check(int k)

{

	long long s=0;

	for (int i=1; i<=k; i++) s+=a[i];

	for (int i=k+1; i<=n; i++)

	{

		if (2*s<a[i]) return 0;

		s+=a[i];

	}

	return 1;

}

int main()

{

//	freopen("B.in", "r", stdin);

//	freopen("B.out", "w", stdout);

	scanf("%d", &n);

	for (int i=1; i<=n; i++) scanf("%d", &a[i]);

	sort(a+1, a+n+1);

	int l=1, r=n;

	while (l<r)

	{

		int mid=l+r>>1;

		if (check(mid)) r=mid;

		else l=mid+1;

	}

	printf("%d\n", n-l+1);

	return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>



#define fr first

#define sc second

#define mk make_pair

#define pb push_back

#define pf push_front

#define pii pair <int ,int>

#define all(s) s.begin (), s.end ()

#define int long long



using namespace std;



const int N = 1e5 + 5;



int n, ar[N], pref[N];



main()

{

    cin >> n;

    for (int i = 1; i <= n; i++)

        scanf("%lld", &ar[i]);



    sort(ar + 1, ar + n + 1);



    for (int i = 1; i <= n; i++)

        pref[i] = ar[i] + pref[i - 1];



    for (int i = n - 1; i >= 0; i--)

    {

        if (pref[i] * 2 < ar[i + 1])

        {

            cout << n - i;

            return 0;

        }

    }



}


// Faster C++ solution for the same problem (measured speedup: 5.223163788716983x):
#include <cstdio>

#include <algorithm>

using namespace std;

const int MAXN=110000;

int n, a[MAXN];

bool check(int k)

{

	long long s=0;

	for (int i=1; i<=k; i++) s+=a[i];

	for (int i=k+1; i<=n; i++)

	{

		if (2*s<a[i]) return 0;

		s+=a[i];

	}

	return 1;

}

int main()

{

//	freopen("B.in", "r", stdin);

//	freopen("B.out", "w", stdout);

	scanf("%d", &n);

	for (int i=1; i<=n; i++) scanf("%d", &a[i]);

	sort(a+1, a+n+1);

	int l=1, r=n;

	while (l<r)

	{

		int mid=l+r>>1;

		if (check(mid)) r=mid;

		else l=mid+1;

	}

	printf("%d\n", n-l+1);

	return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>



#define pb push_back

#define mk make_pair

#define fr first

#define sc second



using namespace std;



const int N = 1e5 + 11;



int n, c, l;

long long a[N], d[N], sm, flag[N];

int main () {



       cin >> n;

       for(int i = 1;i <= n;i ++)

           cin >> a[i];

       c = n;

       sort(a + 1, a + n + 1);



       for(int i = 1;i < n;i ++)

       {

           sm += a[i];

           if(sm * 2 < a[i + 1]) c -= (i - l), l = i;

       }

       cout << c << endl;

}




// Faster C++ solution for the same problem (measured speedup: 5.234458812720756x):
#include <cstdio>

#include <algorithm>

using namespace std;

const int MAXN=110000;

int n, a[MAXN];

bool check(int k)

{

	long long s=0;

	for (int i=1; i<=k; i++) s+=a[i];

	for (int i=k+1; i<=n; i++)

	{

		if (2*s<a[i]) return 0;

		s+=a[i];

	}

	return 1;

}

int main()

{

//	freopen("B.in", "r", stdin);

//	freopen("B.out", "w", stdout);

	scanf("%d", &n);

	for (int i=1; i<=n; i++) scanf("%d", &a[i]);

	sort(a+1, a+n+1);

	int l=1, r=n;

	while (l<r)

	{

		int mid=l+r>>1;

		if (check(mid)) r=mid;

		else l=mid+1;

	}

	printf("%d\n", n-l+1);

	return 0;

}
// Slower C++ solution:
#include <cstdio>

#include <cstring>

#include <string>

#include <iostream>

#include <algorithm>

using namespace std;



typedef long long ll;

const int maxn=1e5+5;

int a[maxn];

ll b[maxn];



int main()

{

    int n;

    scanf("%d",&n);

    for(int i=0;i<n;i++)

        scanf("%d",&a[i]);

    sort(a,a+n);

    b[0]=a[0];

    for(int i=1;i<n;i++)

    {

        b[i]=b[i-1]+a[i];

    }

    int cnt=1;

    for(int i=n-2;i>=0;i--)

    {

        if(b[i]*2>=a[i+1])

            cnt++;

        else

            break;

    }

    printf("%d\n",cnt);

    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.195538936222348x):
#include <cstdio>

#include <algorithm>

using namespace std;

const int MAXN=110000;

int n, a[MAXN];

bool check(int k)

{

	long long s=0;

	for (int i=1; i<=k; i++) s+=a[i];

	for (int i=k+1; i<=n; i++)

	{

		if (2*s<a[i]) return 0;

		s+=a[i];

	}

	return 1;

}

int main()

{

//	freopen("B.in", "r", stdin);

//	freopen("B.out", "w", stdout);

	scanf("%d", &n);

	for (int i=1; i<=n; i++) scanf("%d", &a[i]);

	sort(a+1, a+n+1);

	int l=1, r=n;

	while (l<r)

	{

		int mid=l+r>>1;

		if (check(mid)) r=mid;

		else l=mid+1;

	}

	printf("%d\n", n-l+1);

	return 0;

}
// Slower C++ solution:
#include<stdio.h>

#include<stdlib.h>

#include<string.h>

#define ll long long

int line(const void*a,const void*b)

{

	return *(int *)a-*(ll *)b;

}

int main()

{

	ll s1[100010];

	ll judgesum[100010];

	ll a,n,sum;

	while(scanf("%lld",&n)!=EOF)

	{

		sum=0;

		for(a=1;a<=n;a++)

			scanf("%lld",&s1[a]);

		qsort(s1+1,n,sizeof(s1[1]),line);

		memset(judgesum,0,sizeof(judgesum));

		judgesum[1]=s1[1];

		for(a=2;a<=n;a++)

			judgesum[a]=judgesum[a-1]+s1[a];

		sum=1;

		for(a=n-1;a>=1;a--)

		{

			if(2*judgesum[a]>=s1[a+1])

				sum++;

            else break;

		}

		printf("%lld\n",sum);

	}

	return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.326756320416113x):
#include <cstdio>

#include <algorithm>

using namespace std;

const int MAXN=110000;

int n, a[MAXN];

bool check(int k)

{

	long long s=0;

	for (int i=1; i<=k; i++) s+=a[i];

	for (int i=k+1; i<=n; i++)

	{

		if (2*s<a[i]) return 0;

		s+=a[i];

	}

	return 1;

}

int main()

{

//	freopen("B.in", "r", stdin);

//	freopen("B.out", "w", stdout);

	scanf("%d", &n);

	for (int i=1; i<=n; i++) scanf("%d", &a[i]);

	sort(a+1, a+n+1);

	int l=1, r=n;

	while (l<r)

	{

		int mid=l+r>>1;

		if (check(mid)) r=mid;

		else l=mid+1;

	}

	printf("%d\n", n-l+1);

	return 0;

}
// Slower C++ solution:
#include<iostream>

#include<cstdio>

#include<algorithm>

#include<cmath>

#include<cstring>

#include<string>

#include<vector>

#include<map>

#include<queue>

#include<stack>

using namespace std;

long long s[100005];

long long vis[100005];

int main(){

	int n;

	while(scanf("%d",&n)==1)

	{

		for(int i=0;i<n;i++)

		scanf("%lld",&s[i]);

		sort(s,s+n);

		vis[0]=s[0];

		for(int i=1;i<n;i++)

		vis[i]=vis[i-1]+s[i];

		int sum=0;

		for(int i=n-1;i>=0;i--)

		if(s[i]<=vis[i-1]*2)sum++;

		else break;

		printf("%d\n",sum+1);

	}

	return 0;

} 

// Faster C++ solution for the same problem (measured speedup: 5.155310387007147x):
#include <cstdio>

#include <algorithm>

using namespace std;

const int MAXN=110000;

int n, a[MAXN];

bool check(int k)

{

	long long s=0;

	for (int i=1; i<=k; i++) s+=a[i];

	for (int i=k+1; i<=n; i++)

	{

		if (2*s<a[i]) return 0;

		s+=a[i];

	}

	return 1;

}

int main()

{

//	freopen("B.in", "r", stdin);

//	freopen("B.out", "w", stdout);

	scanf("%d", &n);

	for (int i=1; i<=n; i++) scanf("%d", &a[i]);

	sort(a+1, a+n+1);

	int l=1, r=n;

	while (l<r)

	{

		int mid=l+r>>1;

		if (check(mid)) r=mid;

		else l=mid+1;

	}

	printf("%d\n", n-l+1);

	return 0;

}
// Slower C++ solution:
#include<iostream>

#include<cstdio>

#include<cstring>

#include<queue>

#include<stack>

#include<cmath>

#include<algorithm>

#define inf 99999999

using namespace std;

typedef long long ll;

const int MAX=100000+10;

int cmp(int a,int b){

    return a<b;

}

ll a[MAX],b[MAX];

int main(){

    #ifdef SIYU

    //freopen("in.txt","r",stdin);

    #endif // SIYU

    int n;

    cin>>n;

    for(int i=0;i<n;i++)

        scanf("%lld",&a[i]);

    sort(a,a+n,cmp);

    for(int i=0;i<n;i++){

        if(i==0)    b[i]=a[i];

        else    b[i]=b[i-1]+a[i];

    }

    int countt=0;

    for(int i=n-1;i>=0;i--){

        if(a[i]<=b[i-1]*2)

            countt++;

        else

            break;

    }

    cout<<countt+1<<endl;

    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.235147928233713x):
#include <cstdio>

#include <algorithm>

using namespace std;

const int MAXN=110000;

int n, a[MAXN];

bool check(int k)

{

	long long s=0;

	for (int i=1; i<=k; i++) s+=a[i];

	for (int i=k+1; i<=n; i++)

	{

		if (2*s<a[i]) return 0;

		s+=a[i];

	}

	return 1;

}

int main()

{

//	freopen("B.in", "r", stdin);

//	freopen("B.out", "w", stdout);

	scanf("%d", &n);

	for (int i=1; i<=n; i++) scanf("%d", &a[i]);

	sort(a+1, a+n+1);

	int l=1, r=n;

	while (l<r)

	{

		int mid=l+r>>1;

		if (check(mid)) r=mid;

		else l=mid+1;

	}

	printf("%d\n", n-l+1);

	return 0;

}
// Slower C++ solution:
#include<iostream>

#include<cstdio>

#include<cstring>

#include<cmath>

#include<algorithm>

using namespace std;

long long a[1000000],b[1000000];

int main()

{

    int n;

    scanf("%d",&n);

    for(int i=0;i<n;i++)

    {

        scanf("%lld",&a[i]);

    }

    sort(a,a+n);

    b[0]=a[0];

    for(int i=0;i<n;i++)

    {

        b[i]=b[i-1]+a[i];

    }

    int cnt=0;

    for(int i=n-1;i>=0;i--)

    {

        if(a[i]<=2*b[i-1]) ++cnt;

        else

        {

            break;

        }

    }

    printf("%d\n",cnt+1);

    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.15608404806206x):
#include <cstdio>

#include <algorithm>

using namespace std;

const int MAXN=110000;

int n, a[MAXN];

bool check(int k)

{

	long long s=0;

	for (int i=1; i<=k; i++) s+=a[i];

	for (int i=k+1; i<=n; i++)

	{

		if (2*s<a[i]) return 0;

		s+=a[i];

	}

	return 1;

}

int main()

{

//	freopen("B.in", "r", stdin);

//	freopen("B.out", "w", stdout);

	scanf("%d", &n);

	for (int i=1; i<=n; i++) scanf("%d", &a[i]);

	sort(a+1, a+n+1);

	int l=1, r=n;

	while (l<r)

	{

		int mid=l+r>>1;

		if (check(mid)) r=mid;

		else l=mid+1;

	}

	printf("%d\n", n-l+1);

	return 0;

}
// Slower C++ solution:
#include<iostream>

#include<algorithm>

using namespace std;

long long a[100005],sum[100005];

int main(){

	int n,i;

	long long cont;

	while(cin>>n){

		cont=0;

	 for (i=0;i<n;i++)

	 cin>>a[i];

	 sort(a,a+n);

	 sum[0]=a[0];

	 for (i=1;i<n;i++)

	 sum[i]=sum[i-1]+a[i];

	 for (i=n;i>0;i--)

	 if (a[i]<=sum[i-1]*2)

	 cont++;

	 else

	 break;

	 cout<<cont<<endl;

	}

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.23332586849316x):
#include <cstdio>

#include <algorithm>

using namespace std;

const int MAXN=110000;

int n, a[MAXN];

bool check(int k)

{

	long long s=0;

	for (int i=1; i<=k; i++) s+=a[i];

	for (int i=k+1; i<=n; i++)

	{

		if (2*s<a[i]) return 0;

		s+=a[i];

	}

	return 1;

}

int main()

{

//	freopen("B.in", "r", stdin);

//	freopen("B.out", "w", stdout);

	scanf("%d", &n);

	for (int i=1; i<=n; i++) scanf("%d", &a[i]);

	sort(a+1, a+n+1);

	int l=1, r=n;

	while (l<r)

	{

		int mid=l+r>>1;

		if (check(mid)) r=mid;

		else l=mid+1;

	}

	printf("%d\n", n-l+1);

	return 0;

}
// Slower C++ solution:
#include<stdio.h>

#include<algorithm>

#include<vector>

using namespace std;

int main()

{

    long n,k;

    scanf("%ld",&n);

    k=0;

    vector<long long> a(n);

    long long pre,sum;

    for(int i=0; i<n; i++)

    {

        scanf("%lld",&a[i]);

    }

    sort(a.begin(),a.end());

    pre=a[0];

    for(int i=1; i<n; i++)

    {

        sum=pre+a[i];

        //printf("%lld %lld %lld\n",a[i],pre,sum);

        if(2*pre<a[i]) k=i;

        pre=sum;

    }

    printf("%ld",n-k);





}


// Faster C++ solution for the same problem (measured speedup: 4.833235517698224x):
#include <cstdio>

#include <algorithm>

using namespace std;

const int MAXN=110000;

int n, a[MAXN];

bool check(int k)

{

	long long s=0;

	for (int i=1; i<=k; i++) s+=a[i];

	for (int i=k+1; i<=n; i++)

	{

		if (2*s<a[i]) return 0;

		s+=a[i];

	}

	return 1;

}

int main()

{

//	freopen("B.in", "r", stdin);

//	freopen("B.out", "w", stdout);

	scanf("%d", &n);

	for (int i=1; i<=n; i++) scanf("%d", &a[i]);

	sort(a+1, a+n+1);

	int l=1, r=n;

	while (l<r)

	{

		int mid=l+r>>1;

		if (check(mid)) r=mid;

		else l=mid+1;

	}

	printf("%d\n", n-l+1);

	return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;



int n, a[100001];

long long sum[100001];

int main() {

	cin >> n;

	for(int i = 1; i <= n; i++) cin >> a[i];

	sort(a+1, a+n+1);

	for(int i = 1; i <= n; i++) sum[i] = sum[i-1] + a[i];

	for(int i = n-1; i >= 0; i--) {

		if(a[i+1] > 2*sum[i]) {

			cout << n-i;

			return 0;

		}

	}

}


// Faster C++ solution for the same problem (measured speedup: 5.211672444700153x):
#include <cstdio>

#include <algorithm>

using namespace std;

const int MAXN=110000;

int n, a[MAXN];

bool check(int k)

{

	long long s=0;

	for (int i=1; i<=k; i++) s+=a[i];

	for (int i=k+1; i<=n; i++)

	{

		if (2*s<a[i]) return 0;

		s+=a[i];

	}

	return 1;

}

int main()

{

//	freopen("B.in", "r", stdin);

//	freopen("B.out", "w", stdout);

	scanf("%d", &n);

	for (int i=1; i<=n; i++) scanf("%d", &a[i]);

	sort(a+1, a+n+1);

	int l=1, r=n;

	while (l<r)

	{

		int mid=l+r>>1;

		if (check(mid)) r=mid;

		else l=mid+1;

	}

	printf("%d\n", n-l+1);

	return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>

#define rank tipa_rank

#define pb push_back

#define mp make_pair

#define ll long long

#define ull unsigned long long

#define INF 1000000000

#define EPS 1e-6

#define EPS2 1e-8

using namespace std;

const ll MOD = INF + 7;

using namespace std;

int ans;

int n;

int a[100000];

bool good(int x)

{

	ll sz = 0;

	for(int i = 0; i <= x; i++)

	{

		sz += a[i];

	}

	bool good = true;

	for(int i = x + 1; i < n; i++)

	{

		if(a[i] <= 2 * sz)

		{

			sz += a[i];

		}

		else

		{

			good = false;

			break;

		}

	}

	return good;

}

int main()

{

	scanf("%d" , &n);

	for(int i = 0; i < n; i++)

		scanf("%d" , &a[i]);

	sort(a , a + n);

	int l = 0 , r = n - 1;

	while(abs(r - l) > 1)

	{

		int m = (l + r) / 2;

		if(good(m))

		{

			r = m;

		}

		else

		{

			l = m + 1;

		}

	}

	if(l > r)

	{

		swap(l , r);

	}

	if(good(l))

	{

		cout << n - l;

	}

	else

		cout << n - r;

}


// Faster C++ solution for the same problem (measured speedup: 5.168441764524051x):
#include <cstdio>

#include <algorithm>

using namespace std;

const int MAXN=110000;

int n, a[MAXN];

bool check(int k)

{

	long long s=0;

	for (int i=1; i<=k; i++) s+=a[i];

	for (int i=k+1; i<=n; i++)

	{

		if (2*s<a[i]) return 0;

		s+=a[i];

	}

	return 1;

}

int main()

{

//	freopen("B.in", "r", stdin);

//	freopen("B.out", "w", stdout);

	scanf("%d", &n);

	for (int i=1; i<=n; i++) scanf("%d", &a[i]);

	sort(a+1, a+n+1);

	int l=1, r=n;

	while (l<r)

	{

		int mid=l+r>>1;

		if (check(mid)) r=mid;

		else l=mid+1;

	}

	printf("%d\n", n-l+1);

	return 0;

}