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):
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 

def ii(): return int(sys.stdin.readline().rstrip()) 
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) 
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]

def ss(): return sys.stdin.readline().rstrip() 
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) 
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]





n=ii()
arr=sorted(limii())

s = [0]
for i in range(0, n):
    s.append(s[i] + arr[i])




ans=0

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

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

creatures.sort()

accumulation = []

for i in range(len(creatures)):
    if i == 0:
        accumulation.append(0)
    else:
        accumulation.append(creatures[i-1]+accumulation[i-1])
        
creatures.reverse()
accumulation.reverse()

ans = 0

for i in range(len(creatures)):
    if i == 0:
        ans += 1
    else:
        if creatures[i-1] > (creatures[i] + accumulation[i])*2:
            break
        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 == n-1:
        return True
    y = C[x+1]
    flag = True
    for i in range(x+1, n):
        if A[i] > 2*y:
            flag = False
        y += A[i]
    if flag:
        return True
    else:
        return False

if is_ok(0):
    print(n)
    exit()

l = 0
r = n-1
while l+1 < r:
    c = (l+r)//2
    if is_ok(c):
        r = c
    else:
        l = c
print(n-r)

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 == n-1:
        return True
    y = C[x+1]
    flag = True
    for i in range(x+1, n):
        if A[i] > 2*y:
            flag = False
        y += A[i]
    if flag:
        return True
    else:
        return False

if is_ok(0):
    print(n)
    exit()

l = 0
r = n-1
while l+1 < r:
    c = (l+r)//2
    if is_ok(c):
        r = c
    else:
        l = c
print(n-r)

Solution (Python):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

from itertools import accumulate
from bisect import bisect_left

n, *a = map(int, read().split())
a.sort()
cumsum = list(accumulate(a))
index = bisect_left(cumsum, a[-1] / 2)
cnt = 0
for (bf, af) in zip(cumsum[:index], a[1:index + 1]):
    cnt += 1
    if bf * 2 < af:
        cnt = 0
print((n - index) + cnt)

Solution (Python):
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n=int(input())
    A=[int(_) for _ in input().split()]
    A.sort()
    A_cum=[0]*n
    A_cum[0]=A[0]
    for i in range(1,n):
        A_cum[i]=A_cum[i-1]+A[i]
    for i in range(n-2,-1,-1):
        if 2*A_cum[i]<A[i+1]:
            print(n-1-i)
            break
    else:
        print(n)


if __name__=='__main__':
    main()

Solution (Python):
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n=int(input())
    A=[int(_) for _ in input().split()]
    A.sort()
    A_cum=[0]*n
    A_cum[0]=A[0]
    for i in range(1,n):
        A_cum[i]=A_cum[i-1]+A[i]
    for i in range(n-2,-1,-1):
        if 2*A_cum[i]<A[i+1]:
            print(n-1-i)
            break
    else:
        print(n)


if __name__=='__main__':
    main()

Solution (Python):

from copy import deepcopy
n = int(input())
nums = [int(i) for i in input().split()]
nums.sort()
cums = deepcopy(nums)
for i in range(1, n):
    cums[i] += cums[i - 1]

t = 1
for i in range(n - 1)[::-1]:
    if nums[i + 1] <= cums[i] * 2:
        t += 1
    else:
        break
print(t)

Solution (Python):
N = int(input())
A = sorted(list(map(int, input().split())))
dp = {}
quota = 0
res = 0
size = 0
streak = 1
for i in range(N-1):
  a = A[i]
  size += a
  if A[i+1] <= size*2:
    streak += 1
  else:
    streak = 1

print(streak)

Solution (Python):
import sys
def input(): return sys.stdin.readline().strip()
n=int(input())
a=sorted(map(int,input().split()))
c=0
for i in range(n-1):
    if a[i]*2<a[i+1]:
        c=i+1
    a[i+1]+=a[i]
print(n-c)

Solution (Python):
n=int(input())
a=list(map(int,input().split()))
a.sort()
d=[0]*n
d[0]=1
s=[0]*n
s[0]=a[0]

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

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

ans += 1
print(ans)

Solution (Python):
import bisect

def CS1D(lis): 
    ret=[lis[0]]
    for i in range(1,len(lis)):
        ret.append(ret[i-1]+lis[i])
    return ret
  
N=int(input())
A=[int(a) for a in input().split()]
A.sort()
CS=CS1D(A)
ans=0
for i in range(N):
  w=CS[i]
  prev=-1
  while True:
    tmp=bisect.bisect(A,2*w)-1
    if tmp==N-1:
      ans+=1
      break
    if prev==tmp:
      break
    w=CS[tmp]
    prev=tmp
print(ans)

Solution (Python):
def main():
    import sys
    input = sys.stdin.readline
    N = int(input())
    A = sorted([int(x) for x in input().strip().split()])

    def judge(i):
        m = A[i]
        for j, a in enumerate(A):
            if i == j:
                continue
            if a <= 2 * m:
                m += a
            else:
                return False
        return True
    
    l = -1
    r = N
    while l + 1 < r:
        m = (l + r) // 2
        if judge(m):
            r = m
        else:
            l = m
    
    print(N - (l + 1))

if __name__ == '__main__':
    main()

Solution (Python):
import copy

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

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

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

Solution (Python):
from itertools import accumulate
n = int(input())
a = list(map(int, input().split()))
a.sort()
a_acc = list(accumulate(a))[:-1]
ans = 1
for i in reversed(range(n-1)):
    if a_acc[i] * 2 >= a[i+1]:
        ans += 1
    else: break
print(ans)

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

Solution (Python):
MOD = 10 ** 9 + 7
INF = 10 ** 10
import sys
sys.setrecursionlimit(100000000)
dy = (-1,0,1,0)
dx = (0,1,0,-1)
from itertools import accumulate

def ok(x,A,Acum):
    size = Acum[x]
    for creature in A[x + 1:]:
        if creature  <= 2*size:
            size += creature
    if size == Acum[-1]:
        return True
    return False

def main():
    N = int(input())
    A = list(map(int,input().split()))
    A.sort()
    Acum = list(accumulate(A))
    
    l = -1
    r = N
    while r - l > 1:
        mid = (r + l)//2
        if ok(mid,A,Acum):
            r = mid
        else:
            l = mid
    print(N - r)  
if __name__ == '__main__':
    main()

Solution (Python):
from itertools import accumulate
n = int(input())
a = list(map(int, input().split()))
a.sort()
a_acc = list(accumulate(a))[:-1]
ans = 1
for i in reversed(range(n-1)):
    if a_acc[i] * 2 >= a[i+1]:
        ans += 1
    else: break
print(ans)

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

Solution (Python):
n=int(input())
a=list(map(int,input().split()))
a.sort()
s=[0]
si=0
for ai in a:
    si+=ai
    s.append(si)
import bisect
ans=0

for ai in a:
    b0=0
    b1=1
    c=ai
    while b0!=b1:
        b0=b1
        b1=bisect.bisect_right(a,2*c)
        c=s[b1]
    if b1==n:
        ans+=1
print(ans)

Solution (Python):
import sys

input = sys.stdin.readline


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

    A.sort()
    ans = 1
    S = sum(A)
    for i in reversed(range(N-1)):
        S -= A[i+1]
        if A[i+1] <= 2*S:
            ans += 1
        else:
            break
    print(ans)


if __name__ == "__main__":
    main()

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

A.sort()

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

for i in reversed(range(N-1)):
    if cum[i] * 2 >= A[i+1]:
        continue
    else:
        print(N-1-i)
        break
else:
    print(N)

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

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

Solution (Python):
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

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

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


resolve()

Solution (Python):
N,*A = map(int, open(0).read().split())
A.sort(reverse=True)
s = sum(A)
ans = 1
for i in range(N):
  s -= A[i]
  if 2*s<A[i]:
    break
  ans += 1
print(ans)

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










t = 0
value = A[0]
for k in range(1, n):
    
    
    if 2 * value < A[k]:
        t = max(t, k)
    value += A[k]


print(n - t)

Solution (Python):
import numpy as np
N = int(input())
M = [0] + sorted(list(map(int, input().split())))
C = np.cumsum(M)


for i in range(N-1, -1, -1):
  
  if C[i]*2 < M[i+1]:
    
    break
print(N-i)

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n = int(input())
    A = sorted(list(map(int, input().split())))
    ruiseki = [0] * n
    ruiseki[0] = A[0]
    for i in range(1, n):
        ruiseki[i] = ruiseki[i - 1] + A[i]

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

    print(n - idx)


if __name__ == '__main__':
    resolve()

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

ind = 0
s = animals[0]
for i, a in enumerate(animals[:-1]):
    if animals[i+1] > 2*s:
        ind = i+1
    s += animals[i+1]
print(n-ind)

Solution (Python):
import sys
import math  
import bisect  
import queue  


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


if __name__ == '__main__':
    N = int(input())
    A = list(map(int, input().split()))

    A.sort()

    ans = N
    while True:
        res = A[0]
        cnt = 1
        flag = False
        for i in range(1, len(A)):
            a = A[i]
            if a > 2 * res:
                ans = min(ans, len(A) - i)
                A = [res + a] + A[i + 1:]
                flag = True
                break
            else:
                res += a
        if flag:
            continue
        else:
            break

    print(ans)

Solution (Python):
import sys
import math  
import bisect  
import queue  


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


if __name__ == '__main__':
    N = int(input())
    A = list(map(int, input().split()))

    A.sort()

    ans = N
    while True:
        res = A[0]
        cnt = 1
        flag = False
        for i in range(1, len(A)):
            a = A[i]
            if a > 2 * res:
                ans = min(ans, len(A) - i)
                A = [res + a] + A[i + 1:]
                flag = True
                break
            else:
                res += a
        if flag:
            continue
        else:
            break

    print(ans)

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
A.sort()
U = N
L = -1
while U - L > 1:
    m = (U+L)//2
    x = A[m]
    x1 = A[m]
    f = True
    f1 = True
    for a in A:
        if a == x1 and f1:
            f1 = False
            continue
        if a <= 2 * x:
            x += a
        else:
            f = False
            break
    if f:
        U = m
    else:
        L = m
print(N-U)

Solution (Python):
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])



left=0
for left in range(N-2,-1,-1):
  if B[left]*2>=A[left+1]:
    pass
  else:
    break
else:
  left=-1

num=N-left-1

print(num)

Solution (Python):
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): 
    return list(map(int,input().split()))
def m(): 
    return map(int,input().split())
def onem(): 
    return int(input())
def s(x): 
    a = []
    if len(x) == 0:
        return []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): 
    return " ".join(map(str,x))
def max2(x): 
    return max(map(max,x))
def In(x,a): 
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False

def pow_k(x, n):
    ans = 1
    while n:
        if n % 2:
            ans *= x
        x *= x
        n >>= 1
    return ans

"""
def nibu(x,n,r):
    ll = 0
    rr = r
    while True:
        mid = (ll+rr)//2

    if rr == mid:
        return ll
    if (ここに評価入れる):
        rr = mid
    else:
        ll = mid+1
"""

n = onem()

a = l()

a.sort()

su = 0

po = a[0]

for i in range(1,n):
    if 2 * po < a[i]:
        su = i
    po += a[i]



print(n - su)

Solution (Python):
from itertools import accumulate

N = int(input())
A = list(map(int,input().split()))
A = sorted(A)
S = list(accumulate(A))
AS = []
flg = False
count = 0

for i in range(N-1):
  AS.append(S[i]*2 - A[i+1])
for j in range(N-2,-1,-1):
  if AS[j] < 0:
    count = j+1
    break
print(len(A)-count)

Solution (Python):
n = int(input())
a = list(map(int,input().split()))
a.sort()
ans = [0]*n
ans[n-1] = 1

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

print(aa)

Solution (Python):
from collections import Counter

n = int(input())
aaa = list(map(int, input().split()))
cnt = Counter(aaa)
aaa_unique = list(set(aaa))
aaa_unique.sort(reverse=True)

rs = sum(aaa)

ans = 0
for a in aaa_unique:
    rs -= a * cnt[a]
    ans += cnt[a]
    if a > 2 * rs:
        break
print(ans)

Solution (Python):
n = int(input())
a = [int(x) for x in input().split()]

a.sort()
max_a = a[-1]
ans = 1

l, r = 0, n-1
while r-l > 1:
  key = (r+l)//2
  sub = a[key]
  judge = False
  if sub*2 >= max_a:
    judge = True
  for i in range(n):
    if judge:
      break
    if i == key:
      continue
    if a[i] <= sub*2:
      sub += a[i]
    if sub*2 >= max_a:
      judge = True
      break
  if judge:
    r = key
  else:
    l = key
key = r
if r == n-1 or r == 1:
  sub = a[l]
  judge = False
  if sub*2 >= max_a:
    judge = True
  for i in range(n):
    if judge:
      break
    if i == l:
      continue
    if a[i] <= sub*2:
      sub += a[i]
    if sub*2 >= max_a:
      judge = True
      break
  if judge:
    key = l
print(n-key)

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

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

A.sort()
import copy
cum = copy.copy(A)
for i in range(1,N):
    cum[i] = cum[i-1]+A[i]

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

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


if __name__ == '__main__':
    main()

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

print(N-t)

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

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



for i in range(N - 1, 0, -1):
    
    if A[i] > cumulative[i] * 2:
        print(N - i)
        break
else:
    print(N)

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

def solve():
    unreachable = None
    for i in range(N-2,-1,-1):
        if 2*acum[i] < A[i+1]:
            unreachable = i
            break
    if unreachable is None:
        return N
    return N - 1 - unreachable

print(solve())

Solution (Python):
import bisect

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

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


def solve():
    unreachable = None
    for i in range(N-2,-1,-1):
        bi = bisect.bisect(A, 2*A[i])
        if 2*acum[bi-1] < A[i+1]:
            unreachable = i
            break
    if unreachable is None:
        return N
    return N - unreachable - 1


print(solve())

Solution (Python):


import bisect

N=int(input())

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

A.sort()

sum_A=[]
for item in A:
    if sum_A:
        sum_A.append(sum_A[-1]+item)
    else:
        sum_A.append(item)

ans=0
for i in range(len(A)):
    while i!=len(A):
        index=bisect.bisect_right(A,2*sum_A[i])-1
        if i==index:
            break
        else:
            i=index
    if i==len(A)-1:
        ans+=1

print(ans)

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

a.sort()
count1=0
count2=0
for i in range(n-1):
    count1+=a[i]
    if 2*count1<a[i+1]:
        count2=i+1
print(n-count2)

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

cnt=1
for i in range(1,N,1):
    
    if A[i-1]/2<=cumlsum[i]:
        cnt=cnt+1
    else:
        break
print(cnt)

Solution (Python):
import sys
from itertools import accumulate


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


sys.setrecursionlimit(10 ** 9)


def main():
    N = int(input())
    A = sorted(list(map(int, input().split())))
    B = list(accumulate(A))
    for i in range(N - 1):
        if B[N - i - 2] * 2 >= A[N - i - 1]:
            continue
        else:
            print(i + 1)
            return
    print(N)


if __name__ == "__main__":
    main()

Solution (Python):
import numpy as np

N = int(input())
A = list(map(int, input().split()))
A.sort()
cumsum = np.cumsum(A)
ans = 1

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

print(ans)

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

Solution (Python):

from itertools import accumulate

n = int(input())
a = [int(i) for i in input().split()]
a.sort()
accum = list(accumulate(a))

accum.reverse()
a.reverse()
ind = 1
while(ind < n):
    if accum[ind]*2 >= a[ind-1]:
        ind += 1
    else:
        break
    
print(ind)

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

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

Solution (Python):






import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate


def read_ints():
    return list(map(int, read().split()))


def read_a_int():
    return int(read())


N = read_a_int()
A = read_ints()
A.sort()
no_idx = 0  
s = 0

for i, a in enu(A):
    if s * 2 < a:
        no_idx = i
    s += a

print(N - no_idx)

Solution (Python):
import numpy as np
N = int(input())
A = np.array(list(map(int, input().split())))
A.sort()
cumsum = A.cumsum()





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

Solution (Python):
import heapq

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

A.sort(reverse=True)

def condition(num):
    test=A[:num]+A[num+1:]
    s=A[num]
    heapq.heapify(test)
    while test:
        x=heapq.heappop(test)
        if 2*s>=x:
            s+=x
        else:
            return False
    return True

start=0
end=N-1
while end-start>1:
    t=(end+start)//2
    if condition(t):
        start=t
    else:
        end=t

if condition(end):
    print(end+1)
elif condition(start):
    print(start+1)
else:
    print(0)

Solution (Python):
N=int(input())
a=list(map(int,input().split()))
A=[]
for i in range(N):
    A.append([i,a[i]])
A.sort(key=lambda x:x[1])
sm=0
t=0
for i in range(N-1):
    sm+=A[i][1]
    if 2*sm<A[i+1][1]:
        t=i+1
print(N -t)

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

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

Solution (Python):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

import itertools

n = int(readline())
a = sorted(tuple(map(int, readline().split())))
cnt = 1
cumsum = list(itertools.accumulate(a))
for i in range(1, n):
    if cumsum[i - 1] * 2 < a[i]:
        n -= cnt
        cnt = 0
    cnt += 1
print(n)

Solution (Python):
import numpy as np
N = int(input())
A = np.array(list(map(int, input().split())))
A.sort()
B = np.cumsum(A)

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

print(cnt)

Solution (Python):

from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def S(): return input().rstrip()
def LS(): return S().split()
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = 1e10


def solve():
    def f(x):
        tmp = a[x]
        for i in range(n):
            if i != x:
                if tmp * 2 >= a[i]:
                    tmp += a[i]
                else:
                    return False
        return True
    n = II()
    a = LI()
    a.sort()
    ok = n - 1
    ng = -1
    while ok - ng > 1:
        mid = (ok + ng) // 2
        if f(mid):
            ok = mid
        else:
            ng = mid
    print(n - ok)
    return



if __name__ == '__main__':
    solve()

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
A = LIST()
A.sort()
A_acc = list(accumulate(A))[::-1]
A = A[::-1]
ans = 1
for i in range(1, N):
	if A_acc[i]*2 >= A[i-1]:
		ans += 1
	else:
		break
print(ans)

Solution (Python):
n = int(input())
ai = [int(i) for i in input().split()]

ai.sort()

tmp = ai[0]
num = 0

for i in range(1,n):
    if 2*tmp >= ai[i]:
        num += 1
    else:
        num = 0
    tmp += ai[i]
        
print(num+1)

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

Solution (Python):
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate
import sys
import bisect
import string
import math
import time


def I(): return int(input())


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


def S(): return input()


def MS(): return map(str, input().split())


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


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


def show(*inp, end='\n'):
    if show_flg:
        print(*inp, end=end)


def print_matrix(mat):
    for i in range(len(mat)):
        print(*mat[i])


YNL = {False: 'No', True: 'Yes'}
YNU = {False: 'NO', True: 'YES'}
MOD = 10**9+7
inf = float('inf')
IINF = 10**10
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()

nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']



show_flg = False


def main():
    N = I()
    A = LI()
    A = sorted(A)
    acc = list(accumulate(A))
    mag = []

    for i in range(N-1):
        mag.append(A[i+1] / acc[i])

    
    
    

    ans = 0
    for i in range(len(mag)):
        if mag[i] > 2.0:
            ans = 0
        else:
            ans += 1

    print(ans + 1)


if __name__ == '__main__':
    main()

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

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

print(ans)

Solution (Python):
n=int(input())
l=sorted(list(map(int,input().split())))
ans,s=1,0
for u in l:
  if 2*s>=u:ans+=1
  else:ans=1
  s+=u
print(ans)

Solution (Python):
sel=4

if sel==1: print('Judgement')


if sel==2:
    N=int(input())
    K=int(input())
    if 2*K-1<N:
        print('YES')
    else:
        print('NO')


if sel==3:
    A,B,C=map(int,input().split())
    ans=10**19
    whole=A*B*C
    for a in range(A//2,A//2+2):
        ans=min(ans,abs(whole-a*B*C*2))
    for b in range(B//2,B//2+2):
        ans=min(ans,abs(whole-A*b*C*2))
    for c in range(C//2,C//2+2):
        ans=min(ans,abs(whole-A*B*c*2))
    print(ans)


if sel==4:
    import bisect

    
    def CS1D(lis): 
        ret=[lis[0]]
        for i in range(1,len(lis)):
            ret.append(ret[i-1]+lis[i])
        return ret

    N=int(input())
    A=[int(i) for i in input().split()]
    A.sort()
    CS=CS1D(A)
    ans=0
    
    
    
    
    for i in range(N):
        
        prev=-1
        size=CS[i]
        k=i
        while prev!=k:
            prev=k
            
            k=bisect.bisect(A,2*size)-1 
            
            size=CS[k]
            if k==N-1:
                ans+=1
                break
    print(ans)

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

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

print(n-t)

Solution (Python):
import heapq
n = int(input())
A = list(map(int, input().split()))
heapq.heapify(A)

cnt = 1
prev = heapq.heappop(A)
while A:
    x = heapq.heappop(A)
    if prev > x:
        heapq.heappush(A, prev)
        prev = x
        continue
    if 2*prev < x:
        cnt = 1
    else:
        cnt += 1
    prev += x

print(cnt)