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 collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007


def A():
    n = I()
    b = LI()
    ans = []
    for j in range(n):
        for i in range(len(b))[::-1]:
            if b[i] == i+1:
                x = b.pop(i)
                ans.append(x)
                break
    if b:
        print(-1)
    else:
        print(*ans[::-1],sep = "\n")
    return


def B():
    n,a,b,c,d = LI()
    s = S()
    a -= 1
    b -= 1
    c -= 1
    d -= 1
    k = b
    while b < d:
        if s[b+1] == ".":
            b += 1
        else:
            if s[b+2] == "
                print("No")
                return
            b += 2
    b = k
    if c < d:
        while a < c:
            if s[a+1] == ".":
                a += 1
            else:
                if s[a+2] == "
                    print("No")
                    return
                a += 2
        print("Yes")
    else:
        for i in range(b-1,d):
            if s[i:i+3].count(".") == 3:
                print("Yes")
                return
        print("No")
    return


def C():
    n,a,b,c,d = LI()
    if abs(b-a) > (n-1)*d:
        print("NO")
        return
    if 2*c <= (n-1)*(d-c):
        print("YES")
        return
    mi = a-(n-1)*d
    m = c+d
    f = 1+(n-1)*(d-c)
    if f >= m:
        print("YES")
        return
    if (b-mi)%m < f:
        print("YES")
    else:
        print("NO")
    return


def D():
    s = S()
    n = len(s)
    ans = 0
    for i in range(n):
        if s[i] == "U":
            ans += n-i-1
            ans += 2*i
        else:
            ans += 2*(n-i-1)
            ans += i
    print(ans)
    return


def E():
    n = I()
    a = LI()
    a.sort()
    b = [a[i] for i in range(n)]
    for i in range(n-1):
        b[i+1] += b[i]
    for i in range(n-1)[::-1]:
        if a[i+1] > 2*b[i]:
            break
    else:
        print(n)
        return
    print(n-i-1)
    return


def F():
    n = I()

    return


if __name__ == "__main__":
    E()

Solution (Python):
N = int(input())
A = [0] + sorted(map(int,input().split()))

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

def binary_search(A,func):
    l = 0
    r = len(A)
    if func(0,A):return -1
    if not func(r,A):return r
    while l+1<r:
        i = (l+r)//2
        if func(i,A):
            r = i
        else:
            l = i
    return l

l = binary_search(A,check)
print(N-l)

Solution (Python):

N = int(input())
A = [0] + sorted(map(int,input().split()))

def check(i):
    a = sum(A[:i+1])
    for b in A[i+1:]:
        if a*2>=b:
            a += b
        else:return False
    return True

l = 0
r = N
while l+1<r:
    i = (l+r)//2
    if check(i):
        r = i
    else:
        l = i

print(N-l)

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

sys.setrecursionlimit(10 ** 7)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x) - 1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

from itertools import accumulate

n = ni()
a = list(li())

a.sort()

cum = list(accumulate(a))

ans = 1

for i in range(len(a) - 2, -1, -1):
    if a[i+1] > 2*cum[i]:
        break

    ans += 1

print(ans)

Solution (Python):
import numpy as np

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

A = sorted(A)
C = np.cumsum(A)

ans = 0
cnt = 0

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

ans = cnt + 1

print(ans)

Solution (Python):
import numpy as np

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

A = sorted(A)
C = np.cumsum(A)

ans = 0
cnt = 0

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

ans = cnt + 1

print(ans)

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

Solution (Python):
n = int(input())
creature_list = [ int(v) for v in input().split() ]

def cumsum(inlist):
    s = 0
    outlist = []
    for i in inlist:
        s += i
        outlist.append(s)
    return outlist
creature_list = sorted(creature_list)
creature_list_0 = list(reversed(creature_list))
creature_list = cumsum(creature_list)
creature_list = list(reversed(creature_list))

ans = None
for i in range(1,n):
    if creature_list_0[i-1] > creature_list[i] * 2:
        ans = i
        break
if ans == None:
    ans = n
print(ans)

Solution (Python):
import sys
import numpy as np


def input():
    return sys.stdin.readline().rstrip()


def main():
    n = int(input())
    al = sorted([int(e) for e in input().split()])

    ans = 0
    size = 0
    for a in al:
        if size * 2 < a:
            ans = 1
        else:
            ans += 1
        size += a
    print(ans)


main()

Solution (Python):
n=int(input())
a=list(map(int,input().split()))
a.sort()
l=0
h=n-1
while l<h:
    t=(l+h)//2
    b=sum(a[:t+1])
    for i in range(t+1,n):
        if b*2>=a[-1]:
            h=t
            break
        if b*2<a[i]:
            l=t+1
            break
        b+=a[i]
    else:
        h=t
print(n-l)

Solution (Python):
N=int(input())
A=[0]+sorted(map(int,input().split()))
l=0
r=N
while l+1<r:
    i = (l+r)//2
    a = sum(A[:i+1])
    for j in range(i+1,N):
        if a*2<A[j]: l = i;break
        a += A[j]
    else:
        r = i
print(N-r+1)

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

Solution (Python):
from heapq import *

N = int(input())
*A, = map(int, input().split())
creatures = [(a, 1) for a in A]
heapify(creatures)
ans = N
while len(creatures) > 1:
    a, m = heappop(creatures)
    b, n = heappop(creatures)
    if 2*a < b: ans -= m; m = 0;
    heappush(creatures, (a+b, m+n))
print(ans)

Solution (Python):
N=int(input())
A=sorted(map(int,input().split()))
from itertools import accumulate
B=list(accumulate(A))
a=1
for i in range(N-2,-1,-1):
    if B[i]*2>=A[i+1]:
        a+=1
    else:
        break
print(a)

Solution (Python):
from itertools import accumulate

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




B = sorted(A)
S = list(accumulate([0] + B))
ans = N - next(
    i
    for i in reversed(range(N))
    if B[i] > 2 * S[i]
)

print(ans)

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

Solution (Python):

n=int(input())
a=[int(i) for i in input().split()]
a.sort()
p,ans=0,0
for i in range(n-1):
    p+=a[i]
    if p*2<a[i+1]:
        ans=i+1

print(n-ans)

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

Solution (Python):
from itertools import accumulate
from bisect import bisect

N = int(input())
A = list(map(int, input().split()))
A.sort()
max_a = A[-1]

A_cs = list(accumulate(A))

def can_survive(i): 
  can_absorb = i
  while True:
    cur_volume = A_cs[can_absorb]
    can_absorb_v = A_cs[can_absorb]*2
    if can_absorb_v >= max_a:
      return True
    next_can_absorb = bisect(A,can_absorb_v)-1
    if can_absorb == next_can_absorb:
      return False
    else:
      can_absorb = next_can_absorb



def search(l,r): 
  if r==l+1:
    if can_survive(l):
      return l
    else:
      return r
  c = (l+r)//2
  if can_survive(c):
    return search(l,c)
  else:
    return search(c,r)

x = search(0,N)
print(N-x)

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

A.sort()

def judge(i,A):
    size = A[i]
    flag = True
    for j in range(N):
        if j!=i:
            if 2*size >= A[j]:
                size+=A[j]
            else:
                flag=False
                break
    return flag

def bisect(s,t,A):
    if t-s==1:
        return t
    else:
        i = (s+t)//2
        if judge(i,A):
            return bisect(s,i,A)
        else:
            return bisect(i,t,A)

if judge(0,A):
    print(N)
else:
    print(N-bisect(0,N,A))

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

Solution (Python):
n=int(input())
arr=list(map(int,input().split()))
arr=sorted(arr)
csum=[0]*n
csum[0]=arr[0]
ans=1
for i in range(1,n):
  csum[i]=arr[i]+csum[i-1]
for i in range(1,n):
  if arr[-i]<=csum[-(i+1)]*2:
    ans+=1
  else:
    break
print(ans)

Solution (Python):
n=int(input())
a=sorted(list(map(int,input().split())))
x,s=1,sum(a)
for i in a[::-1]:
    s-=i
    if 2*s<i:break
    x+=1
print(x)

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

Solution (Python):
N=int(input())
A=[int(i) for i in input().split()]
A.sort()
def f(x):
    a=0
    for i in range(x+1):
        a+=A[i]
    for i in range(x+1,N):
        if 2*a<A[i]:
            return False
        a+=A[i]
    return True
if f(0):
    print(N)
    exit()
mi=0
ma=N-1
while ma-mi>1:
    mid=(ma+mi)//2
    if f(mid):
        ma=mid
    else:
        mi=mid
print(N-mi-1)

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

for i in range(N-1):
  curr += A[i]
  if 2*curr < A[i+1]:
    tsugikuenai = i+1
    
print(N - tsugikuenai)

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

def solve(m):
    size = sum(a[:m])
    for j in range(m,n):
        if size*2 >= a[j]:
            size += a[j]
        else:
            return False
    return True

def binary_search(l,r):
    while abs(r-l) >1:
        mid = (l+r)//2
        if solve(mid):
            r = mid
        else:
            l = mid
    return l
print(n-binary_search(0,n))

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

def check(mid):
    size = a[mid]
    for i in range(n):
        if i == mid:
            continue
        if size*2 < a[i]:
            return False
        size += a[i]
    return True
    
if check(0):
    print(n)
else:
    ok, ng = n-1, 0
    while ok-ng > 1:
        mid = (ok + ng) // 2
        if check(mid):
            ok = mid
        else:
            ng = mid
    print(n-ok)

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

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

a.sort()
a.reverse()
asum = sum(a)

ans = 1

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

print(ans)

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

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

A.sort()

B = [0] * (N+1)
for i in range(N):
    B[i+1] = B[i] + A[i]

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

print(ans+1)

Solution (Python):
import heapq

n = int(input())
alist = [(a, 1) for a in map(int, input().split())]

heapq.heapify(alist)

for _ in range(n-1):
  a1 = heapq.heappop(alist)
  a2 = heapq.heappop(alist)
  if a1[0] < a2[0]:
    if a1[0] * 2 < a2[0]:
      heapq.heappush(alist, (a1[0]+a2[0], a2[1]))
    else:
      heapq.heappush(alist, (a1[0]+a2[0], a1[1]+a2[1]))
  elif a2[0] < a1[0]:
    if a2[0] * 2 < a1[0]:
      heapq.heappush(alist, (a1[0]+a2[0], a1[1]))
    else:
      heapq.heappush(alist, (a1[0]+a2[0], a1[1]+a2[1]))
  else:
    heapq.heappush(alist, (a1[0]+a2[0], a1[1]+a2[1]))

print(alist[0][1])

Solution (Python):
def solve():
  n = int(input())
  a = list(int(i) for i in input().split())
  a.sort()
  t = 0
  suma = 0
  for i in range(n):
    if a[i] > 2*suma:
      t = i
    
    suma += a[i]
  print(n-t)

  
solve()

Solution (Python):

N=int(input())
A=sorted(map(int,input().split()))
b=0
c=0
for n in range(N-1):
  b += A[n]
  if b*2 >= A[n+1]:
    c+=1
  else:
    c=0
print(c+1)

Solution (Python):
n =int(input())
a = list(map(int,input().split()))
a.sort()
l,r=0,n
while l != r - 1:
  t = (l + r) // 2
  s = sum(a[:t])
  for m in a[t:]:
    if s * 2 < m:
      l = t
      break
    s += m
  else:
    r = t
print(n - l)

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

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

a.sort()
s = [0 for _ in range(n)]
s[0] = a[0]

for i in range(1, n):
    s[i]  = s[i-1] + a[i]
    
for i in range(n):
    s[i] *= 2

def find(a, x):
    u, l = len(a), -1
    
    while u > l+1:
        md = (u+l) // 2
        if x >= a[md]:
            l = md
        else:
            u = md
    return u - 1      

ans = [0 for _ in range(n)]
for i in range(n):
    cur = i 
    nx  = find(a, s[i])
    while nx != cur:
        cur = nx
        nx  = find(a, s[nx])
    ans[i] = nx
    
count = 0    
for x in ans:
    if x == len(a) - 1:count+=1
print(count)

Solution (Python):
a = int(input())
x=list(map(int,input().split()))
import itertools
x.sort()
c=list(itertools.accumulate(x))
s = 0
c=c[::-1]
x = x[::-1]


for i,(t,l) in enumerate(zip(c[1:],x[:-1])):
    
    if t*2 >= l  :s+=1
    else:break
print(s+1)

Solution (Python):
import sys
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()

from itertools import accumulate

def main():
    N = II()
    A = LI()
    A.sort()
    S = list(accumulate(A))
    ans = 1
    for s, a in zip(S[-2::-1], A[-1::-1]):
        if s * 2 < a:
            break
        ans += 1

    return ans

print(main())

Solution (Python):
n = int(input())
a = sorted(list(map(int, input().split())),reverse=True)
tot = sum(a)
cnt = 1
for i in a:
  tot -= i
  if i > tot*2:
    break
  cnt += 1
print(cnt)

Solution (Python):


def io_generator():
	return input()



def main(io):
	a=int(io())
	l = list(map(int, io().split()))
	
	l.sort(reverse=True)
	m=sum(l[1:])
	pre=l[0]
	num=1
	for val in l[1:]:
		if pre > m*2:
			break
		else:
			num+=1
			pre=val
			m=m-val
		
	return num



if __name__ == "__main__":
	io= lambda : io_generator()
	print (main(io))

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

b = []
c = 0
for i in range(n):
    c += a[i]
    b.append(c)
a.sort(reverse=True)
b.sort(reverse=True)

d = 0
for i in range(1,n):
    if b[i]*2 < a[i-1]:
        d = i
        break
        
if d:
    print(d)
else:
    print(n)

Solution (Python):


import sys


INF = float('inf')
MOD = 10 ** 9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()


def main():
    n = II()
    A = LI()
    A.sort()

    C = [0]
    for a in A:
        C.append(C[-1] + a)

    t = 0
    for i, (a, c) in enumerate(zip(A[1:], C[1:-1])):
        
        if a > 2 * c:
            t = i + 1

    return n - t


print(main())

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

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

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

a.sort()


acum = [0] * (n+1)
for i in range(n):
    acum[i+1] += acum[i] + a[i]

ans = 1  

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

print(ans)

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

a.sort()
acum = [0] * (n+1)


for i in range(n):
    acum[i+1] += acum[i] + a[i]

ans = 1  

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

print(ans)

Solution (Python):
n=int(input())
t=sorted(map(int, input().split()),reverse=True)
sm=sum(t)
ans=0
for i in t:
    sm-=i
    ans+=1
    if i>sm*2:
        break
print(ans)

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

a.sort()
acum = [0] * (n+1)
for i in range(n):
    acum[i+1] += acum[i] + a[i]

ans = 1

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

print(ans)

Solution (Python):
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

from itertools import accumulate

n = ni()
a = list(li())
a.sort()
acc = list(accumulate(a))



ans = 0
for ai, acci in zip(a[-1:0:-1], acc[-2::-1]):
    if 2*acci >= ai:
        ans += 1
    else:
        break
        
        
print(ans+1)

Solution (Python):
def inpl(): return list(map(int, input().split()))
N = int(input())
A = sorted(inpl())
tmp = 1
size = A[0]
for a in A[1:]:
    tmp = tmp * (a <= 2*size) + 1
    size += a
print(tmp)

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

c = 0
kind = N
for i,a in enumerate(A):
    if c*2 < a:
        kind = N - i
    c += a
print(kind)

Solution (Python):
import bisect

n = int(input())
a = sorted(list(map(int, input().split())))
a_t = [0]
for i in range(n):
    a_t.append(a[i] + a_t[i])
a_t = a_t[1:]
ans = 0
mi = 0
for i in range(n):
    index = bisect.bisect_right(a, a[i] * 2) - 1
    if index == n - 1:
        if not mi:
            mi = i
for i in range(n - 1, -1, -1):
    index = bisect.bisect_right(a, a_t[i] * 2) - 1
    if index >= mi:
        mi = i
        ans += 1
print(ans)

Solution (Python):
from itertools import accumulate

import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

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

ans = N

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

Solution (Python):
from itertools import accumulate

import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

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

ans = N

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

Solution (Python):
from itertools import accumulate
n=int(input())
A=list(map(int,input().split()))
A.sort()
S=list(accumulate(A))
cnt=1
for i in range(n-1):
    if 3*S[i]>=S[i+1]:
        cnt+=1
    else:
        cnt=1
print(cnt)

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
A = sorted(A)
preS = sum(A[:-1])
num = 0
for i in range(N - 1, 0, -1):
    if 2 * preS < A[i]:
        num = i
    else:
        preS -= A[i - 1]
print(N - num)

Solution (Python):
from itertools import accumulate
N = int( input())
A = list( map( int, input().split()))
A.sort()
l = -1
r = N-1
B = list( accumulate(A))
while r - l > 1:
    m = (l+r)//2
    
    check = 1
    for i in range(m+1,N):
        if A[i] <= B[i-1]*2:
            pass
        else:
            check = 0
            break
    if check == 1:
        r = m
    else:
        l = m
print(N-r)

Solution (Python):
from itertools import accumulate
N = int( input())
A = list( map( int, input().split()))
A.sort()
l = -1
r = N-1
B = list( accumulate(A))
while r - l > 1:
    m = (l+r)//2
    
    check = 1
    for i in range(m+1,N):
        if A[i] <= B[i-1]*2:
            pass
        else:
            check = 0
            break
    if check == 1:
        r = m
    else:
        l = m
print(N-r)

Solution (Python):
N = int( input())
A = list( map( int, input().split()))
A.sort()
l = -1
r = N-1
while r - l > 1:
    m = (l+r)//2
    now = sum(A[:m+1])
    check = 1
    for i in range(m+1,N):
        if A[i] <= now*2:
            now += A[i]
        else:
            check = 0
            break
    if check == 1:
        r = m
    else:
        l = m
print(N-r)

Solution (Python):
import itertools
n = int(input())
a = [int(m) for m in input().split()]
a.sort()
acculi = list(itertools.accumulate(a))
sym = -1
for i in range(n - 1):
    if 2 * acculi[i] < a[i + 1]:
        sym = i
print(n - sym - 1)

Solution (Python):
a = int(input())
ar = list(map(int,input().split(" ")))
ar.sort()
count = a
total = ar[0]
b = 1
for i in range(1,a):
    if total * 2 < ar[i]:
        count -= b
        b = 0
    b += 1
    total += ar[i]
print(count)

Solution (Python):
from itertools import accumulate

N = int(input())
a_list = list(map(int, input().split()))
a_list.sort()

check = [False for _ in range(N)]

acc = tuple(accumulate(a_list))

for i in range(N - 1):
    if acc[i] * 2 >= a_list[i + 1]:
        check[i] = True
check[N - 1] = True

ans = 0
for c in check:
    if c:
        ans += 1
    else:
        ans = 0
print(ans)

Solution (Python):
import itertools
N = int(input())
A = sorted([int(_) for _ in input().split()])
cumsum = list(itertools.accumulate(A))
ans = N
for i in range(1, N):
    if A[-i] > 2 * cumsum[-i - 1]:
        ans = i
        break
print(ans)

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

a.sort()
cant = 0
for i in range(len(a)):
    if i==0:
        s=a[i]
        continue
    if(s*2<a[i]):
        cant = i
    s += a[i]
print(n-cant)

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

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

Solution (Python):
N=int(input())
A=[int(i) for i in input().split()]
A.sort(key=lambda x:-x)
S=[0]
for i in range(N):
  S.append(S[i]+A[i])
ans=1
for i in range(1,N):
  if A[i-1]<=2*(S[N]-S[i]):
    ans+=1
  else:
    break
print(ans)

Solution (Python):
N = int(input())
A = [int(a) for a in input().split()]
A.sort()
SumA = [0]
for i in range(N):
    SumA.append(SumA[-1] + A[i])

def DS(i, a, b, L = list):
    lower, higher = a, b
    while higher - lower > 1:
        mid = (lower + higher)//2
        if L[mid] > i: higher = mid
        else: lower = mid
    return lower

Ans = 1
for i in reversed(range(N-1)):
    lim = DS(A[i]*2, i, N, A)
    if lim == N-1: Ans += 1
    elif 2 * (SumA[lim+1] - SumA[0]) >= A[lim+1]: Ans += 1
    else: break

print(Ans)

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


b = [a[0]]
for i in range(1,n):
    b.append(b[-1]+a[i])

res = 0
for i in range(1,n):
    if a[i] > b[i-1]*2:
        res = i

print(n-res)

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

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

Solution (Python):
def inpl(): return [int(i) for i in input().split()]
import numpy as np

N = int(input())
A = np.sort(np.array(inpl()))
B = np.cumsum(A)

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

print(ans+1)

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

total_size = 0
muri = 0
for i,size in enumerate(A):
    if total_size*2 < size:
        muri = i
    total_size += size
print(N - muri)

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
A = sorted(A)
if N == 2:
	if A[0] * 2 >= A[1]:
		print(2)
	else:
		print(1)

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

	c += 1
	print(c)

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

Solution (Python):

n = int(input())
a = sorted([int(x) for x in input().split()])

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

if k==-1:
    print(n)
else:
    print(n-k-1)

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

As.sort()

accA = sum(As[:-1])
for i in reversed(range(N - 1)):
    if accA * 2 < As[i + 1]:
        print(N - 1 - i)
        break
    accA -= As[i]
else:
    print(N)

Solution (Python):
n=input()
a=map(int, raw_input().split())
a.sort()
result=-1
sum=0
for cur in a:
	if sum*2<cur:
		result=0
	result+=1
	sum+=cur
print result

Solution (Python):
def getN():
    return int(input())


def getNM():
    return map(int, input().split())


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

N = getN()
size = getList()

size.sort()

acc = 0
lim = 0
for i, si in enumerate(size[:-1]):
    acc += si
    if acc*2 < size[i+1]:
        lim = i+1

print(N-lim)

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

a = list(map(int, input().split()))
a = sorted(a)

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

print(count)

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


B=[0]
for i in range(N):
    B.append(B[i]+A[i])

ans=1
for j in range(N):
    if B[j]*3<B[j+1]:
        ans=1
    else:
        ans+=1
        
print(ans)

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

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

Solution (Python):
N = int(input())
A = [int(i) for i in input().split()]
A.sort()
B=[0 for i in range(N+1)]
for i in range(N):
    B[i+1]=B[i]+A[i]
B=B[1:]
cnt=1
for i in range(N-1):
    if 2*B[i]<A[i+1]:
        cnt=0
    cnt+=1
print(cnt)

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

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

def li(): return [int(x) for x in stdin.readline().split()]
def li_(): return [int(x)-1 for x in stdin.readline().split()]
def lf(): return [float(x) for x in stdin.readline().split()]
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(ns())
def nf(): return float(ns())

from itertools import accumulate

n = ni()
a = li()

a.sort()
a_cum = list(accumulate(a))[::-1]
a.sort(reverse=True)

ans = n

for i in range(n-1):
    if a[i] <= 2*a_cum[i+1]:
        continue
    else:
        ans = i+1
        break
        
print(ans)

Solution (Python):
f = lambda: map(int,input().split())
n = int(input())
a = sorted(list(f()))
s = [a[0]]
for i in range(n-1):
    s.append(s[-1]+a[i+1])
ans = 1
for i in range(2,n+1):
    if s[-i]*2<a[-i+1]:
        break
    ans += 1
print(ans)

Solution (Python):
N=int(input())
A=sorted([int(i) for i in input().split()])
S=[0 for i in range(N)]
S[0]=A[0]
for i in range(N-1):
    S[i+1]=A[i+1]+S[i]
ans=1
for i in range(N-1)[::-1]:
    if 2*S[i]>=A[i+1]:
        ans+=1
    else:
        break
print(ans)

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

max_ng = -1
for i in range(n - 1):
	if a_sum[i] * 2 < a[i + 1]:
		max_ng = i

print(n - max_ng - 1)

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

Solution (Python):

def inpl(): return list(map(int, input().split()))
N = int(input())
A = sorted(inpl())

ans = 1
tmp = A[0]

for a in A[1:]:
    if a <= tmp*2:
        ans += 1
    else:
        ans = 1
    tmp += a

print(ans)

Solution (Python):
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inpl(): return list(map(int, input().split()))
def inpl_s(): return list(input().split())

N = int(input())
aa = inpl()
aa.sort()

tmp = 0
SUM_aa = [0]
for a in aa:
	tmp += a
	SUM_aa.append(tmp)

def solve(ind):
	size = SUM_aa[ind]
	b_ind = ind

	while True:
		ind = bisect.bisect_right(aa,size*2)

		if ind == N:		
			return True
		elif b_ind == ind:	
			return False

		size = SUM_aa[ind]
		b_ind = ind

NG = 0
OK = N

while OK-NG > 1:
	mid = (OK+NG)//2
	if solve(mid):
		OK = mid
	else:
		NG = mid

print(N-OK+1)