Problem:
 Score : 400 points    Problem Statement Snuke found N strange creatures.
Each creature has a fixed color and size. The color and size of the i -th creature are represented by i and A_i , respectively.  Every creature can absorb another creature whose size is at most twice the size of itself.
When a creature of size A and color B absorbs another creature of size C and color D ( C \leq 2 \times A ), they will merge into one creature of size A+C and color B .
Here, depending on the sizes of two creatures, it is possible that both of them can absorb the other.  Snuke has been watching these creatures merge over and over and ultimately become one creature.
Find the number of the possible colors of this creature.      Constraints  2 \leq N \leq 100000  1 \leq A_i \leq 10^9  A_i is an integer.         Input The input is given from Standard Input in the following format:  N  A_1  A_2 … A_N       Output Print the number of the possible colors of the last remaining creature after the N creatures repeatedly merge and ultimately become one creature.        Sample Input 1 3
3 1 4      Sample Output 1 2  The possible colors of the last remaining creature are colors 1 and 3 .
For example, when the creature of color 3 absorbs the creature of color 2 , then the creature of color 1 absorbs the creature of color 3 , the color of the last remaining creature will be color 1 .       Sample Input 2 5
1 1 1 1 1      Sample Output 2 5  There may be multiple creatures of the same size.       Sample Input 3 6
40 1 30 2 7 20      Sample Output 3 4

Solution (Python):
from itertools import accumulate


N, *A = map(int, open(0).read().split())
A.sort()
acc = list(accumulate(A))
ans = N
for i in range(N - 1):
    if 3 * acc[i] < acc[i + 1]:
        ans = N - i - 1
print(ans)

Solution (Python):
import sys
stdin=sys.stdin

ip=lambda: int(sp())
fp=lambda: float(sp())
lp=lambda:list(map(int,stdin.readline().split()))
sp=lambda:stdin.readline().rstrip()

n=ip()
a=lp()

a.sort()

rui=[0]

for i in range(n):
  rui.append(rui[-1]+a[i])
  
ch=1

rui.sort(reverse=True)

for j in range(n):
  if rui[j]<=rui[j+1]*3:
    ch+=1
  else:
    break
print(ch)

Solution (Python):
import numpy as np
n = int(input())
al = sorted(list(map(int, input().split())))
c = list(np.cumsum(al))

ans = 1
for i in range(n-1):
    if c[i]*2 >= al[i+1]:
        ans += 1
    else:
        ans = 1

print(ans)

Solution (Python):
n = int(input())
A = list(map(int, input().split()))
A.sort()
from itertools import accumulate
C = [0]+A
C = list(accumulate(C))

def is_ok(x):
    if x < 0:
        return False
    cur = C[x+1]
    for i in range(x+1, n):
        if A[i] <= 2*cur:
            cur += A[i]
        else:
            break
    else:
        return True
    return False

ng = -1
ok = n-1
while ng+1 < ok:
    c = (ok+ng)//2
    if is_ok(c):
        ok = c
    else:
        ng = c

ans = n-ok
print(ans)

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
sa = sorted(a)
r = []

su = 0
for i in range(n):
  su += sa[i]
  r.append(su)
ans = 1

for i in range(n-1):
  if (r[~i-1]*2 >= sa[~i]):
    ans += 1
  else:
    break
print(ans)

Solution (Python):
import heapq
N = int(input())
A = sorted(list(map(int,input().split())))
heap = []
for i in range(N):
    a = A[i]
    heapq.heappush(heap,(a,1))
while len(heap)>1:
    a,n1 = heapq.heappop(heap)
    b,n2 = heapq.heappop(heap)
    if b<=2*a:
        a += b
        heapq.heappush(heap,(a,n1+n2))
    else:
        a += b
        heapq.heappush(heap,(a,n2))
a,n = heapq.heappop(heap)
print(n)

Solution (Python):

import sys
def main(N, A):
    A.sort()
    s = 0
    dp = [0] * (N + 1)
    for i, a in enumerate(A):
        dp[i + 1] = 1
        if a <= s * 2: dp[i + 1] += dp[i]
        s += a
    print(dp[N])

if __name__ == '__main__':
    input = sys.stdin.readline
    N = int(input())
    *A, = map(int, input().split())
    main(N, A)

Solution (Python):
import itertools
N = int(input())
A = list(map(int, input().split()))
A.sort()
AA = list(itertools.accumulate(A))
for i in range(N-1):
  if AA[N-2-i]*2 < A[N-1-i]:
    print(i+1)
    exit()
print(N)

Solution (Python):
n = int(input())
a = list(map(int, input().split()))

a.sort()

c = 0
s = []
for i in range(n):
  c+=a[i]
  s.append(c)
ng = 0
for i in range(1,n):
  if a[i] > 2*s[i-1]:
    ng = i
print (n-ng)

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
a.sort()
sm = 0
r = [0]*n
r[0]=a[0]
for i in range(1,n):
    if r[i-1]*2 >= a[i]:
        sm += 1
    else:
        sm = 0
    r[i] = r[i-1] + a[i]

print(sm+1)

Solution (Python):
N = int(input())
A = list(map(int, input().split()))

A.sort()
ans = 1

for i in range(1, N):
  if A[i] > A[i - 1] * 2:
    ans = 1
  else:
    ans += 1
  A[i] += A[i - 1]

print(ans)

Solution (Python):
N = int(input())
A = list(map(int, input().split()))

A = sorted(A)

wa = A[0]  
cnt = 1  
for i in range(1, N):
    if 2 * wa >= A[i]:
        cnt += 1
    else:
        cnt = 1
    wa += A[i]
print(cnt)

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
A.sort()
B = [0] * N
B[0] = A[0]
for i in range(1, N):
    B[i] = B[i - 1] + A[i]

ans = 1
for i in range(N - 2, -1, -1):
    if A[i + 1] <= 2 * B[i]:
        ans += 1
    else:
        break

print(ans)

Solution (Python):
n = int(input())
A = list(map(int, input().split()))
A.sort()


for i in range(1, n):
  A[i] += A[i - 1]

k = 0
for i in range(0, n-1):
  if A[i] * 2 < A[i+1] - A[i]:
    k = i + 1
print(n-k)

Solution (Python):

def resolve():
    N = int(input())
    A = sorted(map(int, input().split()))

    idx = 0
    tmp = 0
    for i in range(N):
        if tmp * 2 < A[i]:
            idx = i
        tmp += A[i]

    print(N - idx)


if __name__ == "__main__":
    resolve()

Solution (Python):
n = int(input())
a = list(map(int,input().split()))
a.sort(reverse=True)
sum_a = sum(a)

ans = n
for i in range(1,n):
    sum_a -= a[i-1]
    if a[i-1] <= 2*sum_a:
        pass
    else:
        print(i)
        exit()

print(n)

Solution (Python):
def main():
    N = int(input())
    A = list(map(int, input().split()))
    A.sort()
    cum = 0
    t = 0
    for i in range(N-1):
        cum += A[i]
        if 2*cum < A[i+1]:
            t = i+1
    ans = N - t
    print(ans)

if __name__ == "__main__":
    main()

Solution (Python):
from itertools import accumulate
n = int(input())
a = list(map(int, input().split()))
a.sort()
asum = list(accumulate(a))

ans = 0
for i in range(n-1):
  if asum[i]*2>=a[i+1]:
    ans += 1
  else:
    ans = 0
print(ans+1)

Solution (Python):
import sys
from sys import exit
from collections import deque
from bisect import bisect_left, bisect_right, insort_left, insort_right
from heapq import heapify, heappop, heappush
from itertools import product, permutations, combinations, combinations_with_replacement
from functools import reduce
from math import gcd, sin, cos, tan, asin, acos, atan, degrees, radians

sys.setrecursionlimit(10**6)
INF = 10**20
eps = 1.0e-20
MOD = 10**9+7

def lcm(x,y):
    return x*y//gcd(x,y)
def lgcd(l):
    return reduce(gcd,l)
def llcm(l):
    return reduce(lcm,l)
def powmod(n,i,mod):
    return pow(n,mod-1+i,mod) if i<0 else pow(n,i,mod)
def div2(x):
    return x.bit_length()
def div10(x):
    return len(str(x))-(x==0)
def perm(n,mod=None):
    ans = 1
    for i in range(1,n+1):
        ans *= i
        if mod!=None:
            ans %= mod
    return ans
def intput():
    return int(input())
def mint():
    return map(int,input().split())
def lint():
    return list(map(int,input().split()))
def ilint():
    return int(input()), list(map(int,input().split()))
def judge(x, l=['Yes', 'No']):
    print(l[0] if x else l[1])
def lprint(l, sep='\n'):
    for x in l:
        print(x, end=sep)
def ston(c, c0='a'):
    return ord(c)-ord(c0)
def ntos(x, c0='a'):
    return chr(x+ord(c0))
class counter(dict):
    def __init__(self, *args):
        super().__init__(args)
    def add(self,x,d=1):
        self.setdefault(x,0)
        self[x] += d
    def list(self):
        l = []
        for k in self:
            l.extend([k]*self[k])
        return l
class comb():
    def __init__(self, n, mod=None):
        self.l = [1]
        self.n = n
        self.mod = mod
    def get(self,k):
        l,n,mod = self.l, self.n, self.mod
        k = n-k if k>n//2 else k
        while len(l)<=k:
            i = len(l)
            l.append(l[i-1]*(n+1-i)//i if mod==None else (l[i-1]*(n+1-i)*powmod(i,-1,mod))%mod)
        return l[k]
def pf(x):
    C = counter()
    p = 2
    while x>1:
        k = 0
        while x%p==0:
            x //= p
            k += 1
        if k>0:
            C.add(p,k)
        p = p+2-(p==2) if p*p<x else x
    return C

N,A=ilint()
A.sort()
tmp=0
ans=0
for i in range(N-1):
    if A[i+1]<=2*(tmp+A[i]):
        ans+=1
    else:
        ans=0
    tmp+=A[i]
print(ans+1)

Solution (Python):
import itertools
def main():
    n=int(input())
    a=sorted(map(int,input().split()))
    b=list(itertools.accumulate(a))
    cnt=0
    for i in reversed(range(1, n)):
        if b[i-1]*2 < a[i]:
            return n-i
    return n
            
if __name__ == "__main__":
    print(main())

Solution (Python):
N = int(input())
A = [int(i) for i in input().split()]; A.sort()

B = []; b = 0
for i in A:
    b += i
    B.append(b)

c = 1; w = True
while w:
    if 2*B[N-1-c] >= A[N-c]:
        c += 1
        if c == N: break
    else:
        w = False

print(c)

Solution (Python):

import collections as cl
import sys


def II():
    return int(sys.stdin.readline())


def MI():
    return map(int, sys.stdin.readline().split())


def LI():
    return list(map(int, sys.stdin.readline().split()))


class Solver():
    def __init__(self, target):
        self.target = target

    def bin_search(self, l, r):
        if l + 1 == r:
            if self.check(l):
                return l - 1
            return l

        c = (l+r) // 2

        is_c_achieve = self.check(c)

        if is_c_achieve:
            return self.bin_search(l, c)
        else:
            return self.bin_search(c, r)

    def check(self, c):
        others = cl.deque(self.target)
        others.remove(self.target[c])
        mine = self.target[c]

        while len(others) > 0:
            minest = others.popleft()
            if mine * 2 >= minest:
                mine += minest
            else:
                return False
        return True


def main():
    N = II()
    target = LI()
    target.sort()
    solver = Solver(target)
    ans = solver.bin_search(0, N - 1)
    print(N - ans - 1)


main()

Solution (Python):
n,*A=map(int,open(a:=0).read().split());A=[0]+sorted(A);S=[0]*(n+1)
for i in range(1,n+1):S[i]=S[i-1]+A[i]
for x,y in zip(A[:0:-1],S[-2::-1]):
  a+=1
  if x>y*2:break
print(a)

Solution (Python):
n = int(input())
a = list(map(int, input().split()))

a = sorted(a)

l = 0
r = n

while l < r:
    mid = (l+r)//2

    size = sum(a[:mid+1])
    ptr = mid+1
    ans = True

    while ptr < n:
        if 2*size >= a[ptr]:
            size += a[ptr]
            ptr += 1
        else:
            ans = False
            break

    if ans:
        r = mid
    else:
        l = mid+1

print(n-l)

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
A.sort()
dp, S = 0, 0
for i, a in enumerate(A):
    if S*2 < a:
        dp = i
    S += a
print(N-dp)

Solution (Python):
N = int(input())
A = sorted(map(int,input().split()))


last_impossible = 0
s = 0
for i,a in enumerate(A):
    if a > 2*s:
        last_impossible = i
    s += a

print(N-last_impossible)

Solution (Python):
n=int(input())
a=list(map(int,input().split()))
a.sort(reverse=True)
ssum=sum(a)
ans=1
for i in range(n):
  ssum-=a[i]
  if 2*ssum<a[i]:
    break
  else:
    ans+=1
print(ans)

Solution (Python):
N=int(input())
A=list(map(int,input().split()))
A=sorted(A)
nums=[]
num=0
ans=1
for a in A:
    num+=a
    nums.append(num)
for n in range(N-2,-1,-1):
    if nums[n]*2>=A[n+1]:
        ans+=1
    else:
        break
print(ans)

Solution (Python):
n = int(input())
alst = list(map(int, input().split()))
alst.sort()
pos = 0
total = 0
for i, a in enumerate(alst):
    if a > total * 2:
        pos = i
    total += a
print(n - pos)

Solution (Python):
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil,pi,factorial
    from operator import itemgetter
    def I(): return int(input())
    def MI(): return map(int, input().split())
    def LI(): return list(map(int, input().split()))
    def LI2(): return [int(input()) for i in range(n)]
    def MXI(): return [[LI()]for i in range(n)]
    def SI(): return input().rstrip()
    def printns(x): print('\n'.join(x))
    def printni(x): print('\n'.join(list(map(str,x))))
    inf = 10**17
    mod = 10**9 + 7

    n=I()
    lis=LI()
    lis.sort()
    
    sm=list(accumulate(lis))
    
    count=1
    for i in range(n-1):
        j=n-1-i
        if 2*sm[j-1]>=lis[j]:
            count+=1
        else:
            break
    print(count)
    






if __name__=="__main__":
    main()

Solution (Python):
def resolve():
    '''
    code here
    '''
    N = int(input())
    As = [int(item) for item in input().split()]
    As.sort()
    res = 1
    remain = sum(As)

    for i in range(N-1):
        temp = As[-1 * (i + 1)]
        remain -= temp

        if temp <= remain * 2:
            res += 1
        else:
            break

    print(res)


if __name__ == "__main__":
    resolve()

Solution (Python):
n = int(input())
a = sorted(list(map(int,input().split())))
cum = [a[0]]
for i in range(1,n):
    cum.append(cum[-1]+a[i])

for i in range(n-2,-1,-1):
    if a[i+1] > cum[i]*2:
        print(n-i-1)
        exit()
print(n)

Solution (Python):
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  

N = I()
A = [0] + LI()
A.sort()


def f(n):  
    a = sum(A[i] for i in range(1,n+1))
    for i in range(n+1,N+1):
        if a*2 >= A[i]:
            a += A[i]
        else:
            return False
    return True


left = 0  
right = N  
while left + 1 < right:
    mid = (left + right)//2
    if f(mid):
        right = mid
    else:
        left = mid

print(N-right+1)

Solution (Python):
N=int(input())
A=list(map(int,input().split()))
ans=N
A.sort()

asum=[A[0]]
j=1
for i in range(1,N):
    if asum[i-1]*2<A[i]:
        ans-=j
        j=0
    asum.append(asum[i-1]+A[i])
    j+=1
    
print(ans)

Solution (Python):
import sys

input = sys.stdin.readline

N = int(input())
A = list(map(int, input().split()))

A.sort()

ans = 0

acum = 0
for i in range(N-1):
    acum += A[i]
    if acum * 2 < A[i+1]:
        ans = 0
    else:
        ans += 1

print(ans + 1)

Solution (Python):
from copy import copy
n, *a = map(int, open(0).read().split())
a.sort()
b = copy(a)
for i in range(n - 1):
    b[i + 1] += b[i]

ans = 0
for i in range(n - 1):
    if b[i] * 2 < a[i + 1]:
        ans = i + 1
print(n - ans)

Solution (Python):
def main():
    n = int(input())
    a = list(map(int,input().split()))
    b = [0 for i in range(n + 1)]
    a.sort()
    ans = n
    for i in range(n):
        b[i + 1] = b[i] + a[i]
    for i in range(1,n):
        if b[i + 1] - b[i] >  2 * b[i]:
            ans = n - i
    print(ans)

main()

Solution (Python):
from itertools import accumulate

N = int(input())
A = list([int(x) for x in input().split()])

A.sort()

check = list(accumulate(A))

for key in range(N-1, 0, -1):
    if check[key-1] * 2 < check[key] - check[key-1]:
        print(N - key)
        exit()

print(N)

Solution (Python):
n=int(input())
a=list(map(int,input().split()))

import numpy as np

a=sorted(a)
cum = np.cumsum(a)

cum=list(reversed(cum))
a=list(reversed(a))
ans=1
for i in range(1,n):
    if a[i-1]<=cum[i]*2:
        ans+=1
    else:
        break

print(ans)

Solution (Python):
from itertools import accumulate


def Li():
    return list(map(int, input().split()))


N = int(input())
A = Li()
A.sort()
Asum = list(accumulate(A))
ans = 0
for i in range(N-1):
    if Asum[i]*2 >= A[i+1]:
        ans += 1
    else:
        ans = 0
print(ans+1)

Solution (Python):
N = int(input())
A = list(map(int, input().split()))

A.sort()

def check(sz):
    
    skp = False
    cannot_eat = False
    check = sz
    for i in A:
        if skp == False and sz == i:
            skp = True
            continue

        if i > check * 2:
            cannot_eat = True
            break
        else:
            check += i
    
    return not cannot_eat

ok = N
ng = -1


while abs(ok-ng)>1:
    mid = (ok+ng)//2

    if check(A[mid]):
        
        ok = mid
    else:
        
        ng = mid
    
    

print(N-ok)

Solution (Python):
N = int(input())

A = list(map(int,input().split()))

A.sort()

memo = [0]*N

for i in range(N):
    memo[i] = memo[i-1]+A[i]

for i in range(N-1,0,-1):
    if A[i] <= 2 * memo[i-1]:
        ans = i-1
    else:
        break
print(N-ans)

Solution (Python):
n=int(input())
a=list(map(int,input().split()))
wa=0
a.sort()
count=0
for i in range(n-1):
  if 2*(wa+a[i])>=a[i+1]:
    count+=1
  else:
    count=0
  wa+=a[i]
print(count+1)

Solution (Python):
N=int(input())
A=list(map(int, input().split()))

A=sorted(A)

ans=1
now=A[0]
sums=A[0]
for i in range(N-1):
    if 2*sums>=A[i+1]:
        ans+=1
        
    else:
        ans=1
        
    sums+=A[i+1]
print(ans)

Solution (Python):
import sys

sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))  
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())  
def LS2(): return list(sys.stdin.readline().rstrip())  

N = I()
A = LI()
A.sort()


def f(n):
    a = sum(A[i] for i in range(n+1))
    for i in range(n+1,N):
        if a*2 >= A[i]:
            a += A[i]
        else:
            return False
    return True


left = -1  
right = N-1  
while left + 1 < right:
    mid = (left + right)//2
    if f(mid):
        right = mid
    else:
        left = mid
print(N-right)

Solution (Python):
from itertools import accumulate

n = int(input())
arr = list(map(int, input().split()))

arr.sort()


cumsum = list(accumulate(arr))

result = []
for x, y in zip(arr[1:], cumsum[:-1]):
    if x <= y * 2:
        result.append(True)
    else:
        result.append(False)

if all(result):
    ans = n
else:
    ans = result[::-1].index(False) + 1

print(ans)

Solution (Python):
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N = int(input())
As = list(mapint())
As.sort()
from itertools import accumulate
cumAs = list(accumulate([0]+As))

ans = 0
cum = 0
for i in range(N-1):
    a = As[i]
    cum += a
    if cum*2<As[i+1]:
        ans = 0
    else:
        ans += 1

print(ans+1)

Solution (Python):
from itertools import accumulate

N = int(input())
A = list(map(int, input().split()))
A.sort()
accumA = [*accumulate(A)]
check = [0] * (N-1)
for i in range(N-1):
    if A[i+1] <= 2*accumA[i]:
        check[i] = 1
ans = 1
j = N-2
while check[j]:
    ans += 1
    j -= 1
    if j == -1:
        break
print(ans)

Solution (Python):
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n = inp()
a = inpl()
a.sort()
b = list(itertools.accumulate(a))
for i in range(n-1)[::-1]:
    if b[i]*2 < a[i+1]:
        res = n-i-1
        break
else:
    res = n
print(res)

Solution (Python):
n=int(input())
al=list(map(int, input().split()))  

al.sort()
curr_ans = 1
curr_sum = al[0]
for a in al[1:]:
    if curr_sum*2 >= a:
        curr_ans += 1
        curr_sum += a
    else:
        curr_ans = 1
        curr_sum += a

print(curr_ans)

Solution (Python):
N = int(input())
A = list(map(int,input().split()))
A.sort()
ans = 1
now = A[0]
for i in range(1,N):
  if A[i] > 2*now:
    ans = 1
    now += A[i]
  else:
    ans += 1
    now += A[i]
print(ans)

Solution (Python):
N = int(input())
A = sorted([int(x) for x in input().split()])

color_min = 0
creature_size = A[0]

for i in range(1, N):
    if 2 * creature_size >= A[i]:
        creature_size += A[i]
    else:
        color_min = i
        creature_size += A[i]

ans = N - color_min

print(ans)

Solution (Python):
n = int(input())
a = sorted(list(map(int, input().split())))

ans, val = 1, a[0]
for i in range(n-1):
    if val*2 >= a[i+1]:
        ans += 1
    else:
        ans = 1
    val += a[i+1]
print(ans)

Solution (Python):
n=int(input())
a=list(sorted(map(int,input().split())))
s=0
t=0
for i in range(n-1):
  s+=a[i]
  if a[i+1]>2*s:
    t=i+1
print(n-t)

Solution (Python):
def main():
    N = int(input())
    A = list(map(int, input().split()))
    A.sort()
    S = [0] * N  
    S[0] = A[0]
    for n in range(1, N):
        S[n] = S[n - 1] + A[n]
    n = N - 2
    while n >= 0:
        if 2 * S[n] < A[n + 1]:  
            break
        n -= 1
    print(N - 1 - n)


if __name__ == '__main__':
    main()

Solution (Python):
n = int(input())
a = list(map(int,input().split()))
a.sort(reverse=True)

size = sum(a)
capa = size*2
count = 1

for i,x in enumerate(a[1:]):
    size -= a[i]
    capa = size * 2
    if a[i] <= capa:
        count += 1
    else:
        break

print(count)

Solution (Python):
N = int(input())
A = list(map(int, input().split()))

A.sort()

ans = 0
total = A[0]
for i in range(N-1):
    if total*2 >= A[i+1]:
        ans += 1
    else:
        ans = 0
    total += A[i+1]

print(ans+1)

Solution (Python):
import sys
readline = sys.stdin.readline

N = int(readline())
A = list(map(int,readline().split()))

A = sorted(A)

cur = 0
ng = 0
for i in range(N):
  if A[i] > cur * 2:
    ng = i
  cur += A[i]
  
print(N - ng)

Solution (Python):
N = int(input())

A = list(map(int, input().split()))

A.sort()
sum_val = [0] * N
sum_val[0] = A[0]
for i in range(1, N):
    sum_val[i] = sum_val[i - 1] + A[i]

ans = 1
for i in range(N - 2, -1, -1):
    if 2 * sum_val[i] >= A[i + 1]:
        ans += 1
    else:
        break
print(ans)

Solution (Python):
import sys
import numpy as np

read = sys.stdin.read
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def main():
    N = int(input())
    A = np.array(input().split(), np.int64)
    A = np.sort(A)
    Acum = np.cumsum(A)
    ans = 1
    for i in range(N-2,-1,-1):
        if Acum[i]*2 >= A[i+1]:
            ans += 1
        else:
            break
    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
N = int(input())
A = sorted(map(int, input().split()))
sum_A = sum(A)
count = N
for i in range(N - 1, -1, -1):
    sum_A -= A[i]
    if (sum_A) * 2 >= A[i]:
        continue

    else:
        if (i == 0):
            continue
        count -= len(A[0:i])
        break

print(count)

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
A.sort()

ru = [A[0]]
for i in range(1, N):
    ru.append(A[i]+ru[-1])

x = 0
for i in range(N-1, 0, -1):
    if ru[i-1]*2 < A[i]:
        x = i
        break

print(N-x)

Solution (Python):

import sys

sysread = sys.stdin.buffer.readline
read = sys.stdin.buffer.read


sys.setrecursionlimit(10**7)
import math

import bisect
import numpy as np




INF = 1 << 50


def run():
    N, *A = map(int, read().split())
    A = sorted(A)
    B = []
    val = 0
    for a in A:
        val += a
        B.append(val)

    left = -1
    right = -1
    for i in range(N-1):
        if B[i] * 3 >= B[i+1]:
            if left == -1:
                left = i
                right = i+1
            else:
                right = i+1
        else:
            left, right = -1, -1
    print(right - left + 1)


if __name__ == "__main__":
    run()

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
a.sort()
t = 0
s = 0
for i in range(n-1):
    s += a[i]
    if 2 * s < a[i + 1]:
        t = i + 1

print(n-t)

Solution (Python):
N = int(input())
A = list(map(int,input().split()))
A.sort()
S = A[0]
ind=0
for i in range(1,N):
    if A[i]>2*S:
        ind=i
    S+=A[i]
print(N-ind)

Solution (Python):

printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True 
BIG = 10**18
R = 10**9 + 7


def ddprint(x):
  if DBG:
    print(x)

n = inn()
a = inl()
a.sort()
acc = [0]*(n+1)
for i in range(1,n):
    acc[i] = acc[i-1]+a[i-1]


for i in range(n-1,-1,-1):
    if a[i]>2*acc[i]:
        print(n-i)
        exit()

Solution (Python):

n,*a=map(int, open(0).read().split())
a.sort()
ans = 0
c  = 0
for i in range(n-1):
    c += a[i]
    if c*2 < a[i+1]:
        ans = 0
    else:
        ans += 1
print(ans + 1)

Solution (Python):






N = int(input())
A = sorted(list(map(int, input().split())))





tmp = 0
asm = []
for i in range(N):
    tmp += A[i]
    asm += [tmp]
ans = 1
for i in range(2,N+1):
    if asm[-i]*2 >= A[-i+1]:
        ans += 1
    else:
        break
print(ans)

Solution (Python):
N,*A = map(int, open(0).read().split())
A.sort()
ans = 1
cs = 0
for i in range(N-1):
    cs += A[i]
    if cs * 2 >= A[i+1]:
        ans += 1
    else:
        ans = 1
print(ans)

Solution (Python):
N=int(input())
*A,=map(int,input().split())
A.sort()
ans=1
S=0
i=0
while i+1<N:
    S+=A[i]
    if 2*S>=A[i+1]:
        ans+=1
    else:
        ans=1
    i+=1
print(ans)

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
a.sort()
b = [0]
for i in range(n):
    b.append(b[-1] + a[i])
count = 1
for i in range(n - 1):
    if b[n - i - 1] * 2 >= a[n - i - 1]:
        count += 1
    else:
        break
print(count)

Solution (Python):
N = int(input())
A = list(map(int,input().split()))
A.sort()
cum = [0]*(N)
now = 0
for i in range(N):
  now += A[i]
  cum[i] = now
ans = 0
for i in range(1,N):
  if 2*cum[i-1] < A[i]:
    ans = i
print(N-ans)

Solution (Python):

def General_Binary_Search(L,R,cond,Mode=True,Integer=True,ep=1/(1<<20)):
    """一般的な二部探索を行う.
    L:解の下限
    R:解の上限
    cond:条件(1変数関数,広義単調減少 or 広義単調減少を満たす)
    Mode:True->広義単調増加,False->広義単調減少
    Integer:解を整数に制限するか?
    ep:Integer=Falseのとき,解の許容する誤差
    """

    if Integer:
        if Mode:
            if not cond(R):
                return R+1
            L-=1
        else:
            if not cond(L):
                return L-1
            R+=1

        while R-L>1:
            C=L+(R-L)//2
            if cond(C)^Mode:
                L=C
            else:
                R=C
        if Mode:
            return R
        else:
            return L
    else:
        C=L+(R-L)/2
        while (R-C)>ep:
            if cond(C)^Mode:
                L=C
            else:
                R=C
            C=L+(R-L)/2
        return C

def g(x):
    S=A[x]
    for i in range(N):
        if i!=x:
            if A[i]<=2*S:
                S+=A[i]
            else:
                return False
    return True

N=int(input())
A=list(map(int,input().split()))

A.sort()
print(N-General_Binary_Search(0,N-1,g,True))

Solution (Python):

def General_Binary_Search(L,R,cond,Mode=True,Integer=True,ep=1/(1<<20)):
    """一般的な二部探索を行う.
    L:解の下限
    R:解の上限
    cond:条件(1変数関数,広義単調減少 or 広義単調減少を満たす)
    Mode:True->広義単調増加,False->広義単調減少
    Integer:解を整数に制限するか?
    ep:Integer=Falseのとき,解の許容する誤差
    """

    if Integer:
        if Mode:
            if not cond(R):
                return R+1
            L-=1
        else:
            if not cond(L):
                return L-1
            R+=1

        while R-L>1:
            C=L+(R-L)//2
            if cond(C)^Mode:
                L=C
            else:
                R=C
        if Mode:
            return R
        else:
            return L
    else:
        C=L+(R-L)/2
        while (R-C)>ep:
            if cond(C)^Mode:
                L=C
            else:
                R=C
            C=L+(R-L)/2
        return C

def g(x):
    S=A[x]
    for i in range(N):
        if i!=x:
            if A[i]<=2*S:
                S+=A[i]
            else:
                return False
    return True

N=int(input())
A=list(map(int,input().split()))

A.sort()

if not g(N-1):
    print(0)
elif g(0):
    print(N)
else:
    print(N-General_Binary_Search(0,N-1,g,True))

Solution (Python):
n = int(input())
a = sorted(map(int, input().split()))
cs = [0]
for i in range(n):
    cs.append(cs[i]+a[i])


ans = 1
for i in range(n-1)[::-1]:
    if 2*cs[i+1] >= a[i+1]:
        ans += 1
    else:
        break
        

print(ans)

Solution (Python):
import sys
input = sys.stdin.readline

def judge(x):
    B = [A[i] for i in range(N) if i!=x]
    now = A[x]
    
    for Bi in B:
        if Bi>2*now:
            return False
            
        now += Bi
    
    return True

def binary_search():
    l, r = 0, N-1
    
    while l<=r:
        m = (l+r)//2
        
        if judge(m):
            r = m-1
        else:
            l = m+1
    
    return l
    
N = int(input())
A = list(map(int, input().split()))
A.sort()
print(N-binary_search())

Solution (Python):
n = int(input())
l = sorted(list(map(int, input().split())))
idx = 0
cum = 0
for i in range(n-1):
    cum += l[i]
    if cum*2 < l[i+1]:
        idx = i+1
print(n-idx)

Solution (Python):
n = int(input())
a = list(map(int,input().split()))
s = [0 for _ in range(n)]
a.sort()
t = 0
for i in range(n):
  t += a[i]
  s[i] = t
c = 1
for i in range(n-1,0,-1):
  if a[i] <= 2*s[i-1]:
    c += 1
  else:
    break
print(c)

Solution (Python):
n = int(input())
al = list(map(int, input().split()))
al.sort()

c_sum = al[0]
cnt = 1
for a in al[1:]:
    if c_sum*2 >= a:
        c_sum += a
        cnt += 1
    else:
        c_sum += a
        cnt = 1

print(cnt)

Solution (Python):
def main():
    import sys
    input = lambda:sys.stdin.readline().strip()
    
    N = int(input())
    A = list(map(int,input().split()))
    A.sort()

    
    from itertools import accumulate
    acc_A = list(accumulate(A))

    ans = 1
    for i in range(N-2,-1,-1):
        if acc_A[i]*2<(acc_A[i+1]-acc_A[i]):
            break
        else:
            ans+=1

    print(ans)

    
if __name__=='__main__':
    main()

Solution (Python):


import sys
input = sys.stdin.buffer.readline

n = int(input())
A = sorted([int(i) for i in input().strip().split()])
_max = A[-1]
cul_sum = [0] * (n + 1)

for i in range(1, n + 1):
    cul_sum[i] = cul_sum[i - 1] + A[i - 1]

ptr = 0
for i in range(1, n + 1):
    if cul_sum[i] * 2 < A[i]:
        ptr = i
    elif cul_sum[i] * 2 >= _max:
        print(n - ptr)
        sys.exit()

Solution (Python):
n = int(input())
a = list(map(int,input().split()))
a.sort()

l = 0
r = n - 1

def hantei(c):
    a1 = a[:c] + a[c+1:]
    tmp = a[c]
    flag = True
    for i in a1:
        if tmp * 2 >= i:
            tmp += i
        else:
            flag = False
            break
    return flag


while r - l > 1:
    c = int((l + r)//2)
    if hantei(c):
        r = c
    else:
        l = c

if hantei(l):
    print(n - l)
else:
    print(n - l - 1)

Solution (Python):
N = int(input())
As = list(map(int, input().split()))

As.sort()

Ss = [As[0]]

for i in range(1,N):
  Ss.append(Ss[-1] + As[i])
  
cnt = 0
for i in range(N-1):
  if 2*Ss[i] < As[i+1]:
    cnt = i+1
    
print(N-cnt)