stablegradients/pie-gem5-pairs huggingface dataset:
// 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.2377474498327246x):
// hi yhoam



#include <cstdio>

#include <algorithm>



using namespace std;



long long A[int(1e6)+5];



int main(){

    int N;

    scanf("%d",&N);

    for(int c = 0 ; c < N ; c++)

        scanf("%lld",&A[c]);

    sort(A, A+N);

    int sol = 1;

    long long run = A[0];

    for(int c = 1 ; c < N ; c++){

        if(run*2 >= A[c])

            sol++;

        else

            sol = 1;

        run += A[c];

        // printf("%d; %d %d\n",A[c],sol,run);

    }

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

}
// 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.158644310357031x):
// hi yhoam



#include <cstdio>

#include <algorithm>



using namespace std;



long long A[int(1e6)+5];



int main(){

    int N;

    scanf("%d",&N);

    for(int c = 0 ; c < N ; c++)

        scanf("%lld",&A[c]);

    sort(A, A+N);

    int sol = 1;

    long long run = A[0];

    for(int c = 1 ; c < N ; c++){

        if(run*2 >= A[c])

            sol++;

        else

            sol = 1;

        run += A[c];

        // printf("%d; %d %d\n",A[c],sol,run);

    }

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

}
// 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.23592448534531x):
// hi yhoam



#include <cstdio>

#include <algorithm>



using namespace std;



long long A[int(1e6)+5];



int main(){

    int N;

    scanf("%d",&N);

    for(int c = 0 ; c < N ; c++)

        scanf("%lld",&A[c]);

    sort(A, A+N);

    int sol = 1;

    long long run = A[0];

    for(int c = 1 ; c < N ; c++){

        if(run*2 >= A[c])

            sol++;

        else

            sol = 1;

        run += A[c];

        // printf("%d; %d %d\n",A[c],sol,run);

    }

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

}
// 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.2186806152706975x):
#include<stdio.h>

#include<algorithm>

using namespace std;

long long msize[100005],qsum[100005];

main()

{

    long long num;

    scanf("%lld",&num);

    for(long long i=0;i<num;i++)

    {

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

    }

    sort(msize,msize+num);

    qsum[0]=msize[0];

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

    {

        qsum[i]=qsum[i-1]+msize[i];

    }

    long long cnt=1,chk=0;

    for(long long i=num-2;i>=0;i--)

    {

        chk=0;

        if(msize[i+1]<=qsum[i]*2) cnt++;

        else break;

    }

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

}
// 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.221502358022798x):
#include<stdio.h>

#include<algorithm>

using namespace std;

long long msize[100005],qsum[100005];

main()

{

    long long num;

    scanf("%lld",&num);

    for(long long i=0;i<num;i++)

    {

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

    }

    sort(msize,msize+num);

    qsum[0]=msize[0];

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

    {

        qsum[i]=qsum[i-1]+msize[i];

    }

    long long cnt=1,chk=0;

    for(long long i=num-2;i>=0;i--)

    {

        chk=0;

        if(msize[i+1]<=qsum[i]*2) cnt++;

        else break;

    }

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

}
// 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.219470138314776x):
#include<stdio.h>

#include<algorithm>

using namespace std;

long long msize[100005],qsum[100005];

main()

{

    long long num;

    scanf("%lld",&num);

    for(long long i=0;i<num;i++)

    {

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

    }

    sort(msize,msize+num);

    qsum[0]=msize[0];

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

    {

        qsum[i]=qsum[i-1]+msize[i];

    }

    long long cnt=1,chk=0;

    for(long long i=num-2;i>=0;i--)

    {

        chk=0;

        if(msize[i+1]<=qsum[i]*2) cnt++;

        else break;

    }

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

}
// 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.228112876452938x):
#include<stdio.h>

#include<algorithm>

using namespace std;

long long msize[100005],qsum[100005];

main()

{

    long long num;

    scanf("%lld",&num);

    for(long long i=0;i<num;i++)

    {

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

    }

    sort(msize,msize+num);

    qsum[0]=msize[0];

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

    {

        qsum[i]=qsum[i-1]+msize[i];

    }

    long long cnt=1,chk=0;

    for(long long i=num-2;i>=0;i--)

    {

        chk=0;

        if(msize[i+1]<=qsum[i]*2) cnt++;

        else break;

    }

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

}
// 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.239418602794802x):
#include<stdio.h>

#include<algorithm>

using namespace std;

long long msize[100005],qsum[100005];

main()

{

    long long num;

    scanf("%lld",&num);

    for(long long i=0;i<num;i++)

    {

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

    }

    sort(msize,msize+num);

    qsum[0]=msize[0];

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

    {

        qsum[i]=qsum[i-1]+msize[i];

    }

    long long cnt=1,chk=0;

    for(long long i=num-2;i>=0;i--)

    {

        chk=0;

        if(msize[i+1]<=qsum[i]*2) cnt++;

        else break;

    }

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

}
// 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.200461848669872x):
#include<stdio.h>

#include<algorithm>

using namespace std;

long long msize[100005],qsum[100005];

main()

{

    long long num;

    scanf("%lld",&num);

    for(long long i=0;i<num;i++)

    {

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

    }

    sort(msize,msize+num);

    qsum[0]=msize[0];

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

    {

        qsum[i]=qsum[i-1]+msize[i];

    }

    long long cnt=1,chk=0;

    for(long long i=num-2;i>=0;i--)

    {

        chk=0;

        if(msize[i+1]<=qsum[i]*2) cnt++;

        else break;

    }

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

}
// 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.331803564853429x):
#include<stdio.h>

#include<algorithm>

using namespace std;

long long msize[100005],qsum[100005];

main()

{

    long long num;

    scanf("%lld",&num);

    for(long long i=0;i<num;i++)

    {

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

    }

    sort(msize,msize+num);

    qsum[0]=msize[0];

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

    {

        qsum[i]=qsum[i-1]+msize[i];

    }

    long long cnt=1,chk=0;

    for(long long i=num-2;i>=0;i--)

    {

        chk=0;

        if(msize[i+1]<=qsum[i]*2) cnt++;

        else break;

    }

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

}
// 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.160195181825663x):
#include<stdio.h>

#include<algorithm>

using namespace std;

long long msize[100005],qsum[100005];

main()

{

    long long num;

    scanf("%lld",&num);

    for(long long i=0;i<num;i++)

    {

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

    }

    sort(msize,msize+num);

    qsum[0]=msize[0];

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

    {

        qsum[i]=qsum[i-1]+msize[i];

    }

    long long cnt=1,chk=0;

    for(long long i=num-2;i>=0;i--)

    {

        chk=0;

        if(msize[i+1]<=qsum[i]*2) cnt++;

        else break;

    }

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

}
// 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.240108371263186x):
#include<stdio.h>

#include<algorithm>

using namespace std;

long long msize[100005],qsum[100005];

main()

{

    long long num;

    scanf("%lld",&num);

    for(long long i=0;i<num;i++)

    {

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

    }

    sort(msize,msize+num);

    qsum[0]=msize[0];

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

    {

        qsum[i]=qsum[i-1]+msize[i];

    }

    long long cnt=1,chk=0;

    for(long long i=num-2;i>=0;i--)

    {

        chk=0;

        if(msize[i+1]<=qsum[i]*2) cnt++;

        else break;

    }

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

}
// 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.160969575945169x):
#include<stdio.h>

#include<algorithm>

using namespace std;

long long msize[100005],qsum[100005];

main()

{

    long long num;

    scanf("%lld",&num);

    for(long long i=0;i<num;i++)

    {

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

    }

    sort(msize,msize+num);

    qsum[0]=msize[0];

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

    {

        qsum[i]=qsum[i-1]+msize[i];

    }

    long long cnt=1,chk=0;

    for(long long i=num-2;i>=0;i--)

    {

        chk=0;

        if(msize[i+1]<=qsum[i]*2) cnt++;

        else break;

    }

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

}
// 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.238284585072174x):
#include<stdio.h>

#include<algorithm>

using namespace std;

long long msize[100005],qsum[100005];

main()

{

    long long num;

    scanf("%lld",&num);

    for(long long i=0;i<num;i++)

    {

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

    }

    sort(msize,msize+num);

    qsum[0]=msize[0];

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

    {

        qsum[i]=qsum[i-1]+msize[i];

    }

    long long cnt=1,chk=0;

    for(long long i=num-2;i>=0;i--)

    {

        chk=0;

        if(msize[i+1]<=qsum[i]*2) cnt++;

        else break;

    }

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

}
// 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.837815137942432x):
#include<stdio.h>

#include<algorithm>

using namespace std;

long long msize[100005],qsum[100005];

main()

{

    long long num;

    scanf("%lld",&num);

    for(long long i=0;i<num;i++)

    {

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

    }

    sort(msize,msize+num);

    qsum[0]=msize[0];

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

    {

        qsum[i]=qsum[i-1]+msize[i];

    }

    long long cnt=1,chk=0;

    for(long long i=num-2;i>=0;i--)

    {

        chk=0;

        if(msize[i+1]<=qsum[i]*2) cnt++;

        else break;

    }

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

}
// 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.220996932992228x):
#include <stdio.h>

#include <algorithm>

using namespace std;

main()

{

    int num;

    scanf("%d",&num);

    int animal[num];

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

    {

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

    }

    sort(animal,animal+num);

    long long sum=animal[0];

    long long cnt=1;

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

    {

        if (sum*2>=animal[i])

        {

            cnt++;

        }

        else

        {

            cnt=1;

        }

        sum+=animal[i];

    }

    printf("%d",cnt);

}
// 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.223819928178273x):
#include <stdio.h>

#include <algorithm>

using namespace std;

main()

{

    int num;

    scanf("%d",&num);

    int animal[num];

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

    {

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

    }

    sort(animal,animal+num);

    long long sum=animal[0];

    long long cnt=1;

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

    {

        if (sum*2>=animal[i])

        {

            cnt++;

        }

        else

        {

            cnt=1;

        }

        sum+=animal[i];

    }

    printf("%d",cnt);

}
// 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.221786806467068x):
#include <stdio.h>

#include <algorithm>

using namespace std;

main()

{

    int num;

    scanf("%d",&num);

    int animal[num];

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

    {

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

    }

    sort(animal,animal+num);

    long long sum=animal[0];

    long long cnt=1;

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

    {

        if (sum*2>=animal[i])

        {

            cnt++;

        }

        else

        {

            cnt=1;

        }

        sum+=animal[i];

    }

    printf("%d",cnt);

}
// 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.230433380695036x):
#include <stdio.h>

#include <algorithm>

using namespace std;

main()

{

    int num;

    scanf("%d",&num);

    int animal[num];

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

    {

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

    }

    sort(animal,animal+num);

    long long sum=animal[0];

    long long cnt=1;

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

    {

        if (sum*2>=animal[i])

        {

            cnt++;

        }

        else

        {

            cnt=1;

        }

        sum+=animal[i];

    }

    printf("%d",cnt);

}