CodeEff/ECCO huggingface dataset:
# Original solution
n=int(eval(input()))
list=[[0]*n]
list=input().split()
for i in range(n):
  list[i]=int(list[i])

yen=1000
stock=0
keikou=0
for i in range(1,n):
  if list[i]-list[i-1]<=0:
    keikou+=1
if keikou!=n-1:
  for t in range(1,n):
    if list[t]-list[t-1]>=0:
      while(yen>=list[t-1]):
        yen-=list[t-1]
        stock+=1
      yen+=list[t]*stock
      stock=0
print(yen)

# Optimized solution
n=int(eval(input()))
list=[[0]*n]
list=input().split()
for i in range(n):
  list[i]=int(list[i])

yen=1000
stock=0
keikou=0
for i in range(1,n):
  if list[i]-list[i-1]<=0:
    keikou+=1
if keikou!=n-1:
  for t in range(1,n):
    if list[t]-list[t-1]>=0:
      stock+=int(yen/list[t-1])
      yen-=list[t-1]*int(yen/list[t-1])
      yen+=list[t]*stock
      stock=0
print(yen)
# Original solution
n = int(eval(input()))
a = list(map(int,input().split()))
m = 1000
kabu = 0
for i in range(n-1):
    if a[i] < a[i+1]:
        kabu += m//a[i]
        m -= (m//a[i])*a[i]
    else:
        m += a[i]*kabu
        kabu = 0
print((m+kabu*a[-1]))

# Optimized solution
n = int(eval(input()))
a = list(map(int,input().split()))

m = 1000
kabu = 0
for i in range(n-1):
    if a[i] < a[i+1]:
        x = m//a[i]
        kabu += x
        m -= x*a[i]
    else:
        m += kabu*a[i]
        kabu = 0
print((m+(kabu*a[-1])))
# Original solution
n = int(eval(input()))
a = list(map(int, input().split()))

dp = [[-1]*n for i in range(5000)]
for i in range(1000//a[0]+1):
    dp[i][0] = 1000-a[0]*i

for i in range(1, n):
    for g in range(5000):
        for l in range(5000):
            if dp[l][i-1] >= 0:
                if l < g:
                    dp[g][i] = max(dp[l][i-1] - a[i]*(g-l), dp[g][i])
                else:
                    dp[g][i] = max(dp[l][i-1] + a[i]*(l-g), dp[g][i])
            else:
                break

ans = 0
for m in range(5000):
    ans = max(ans, dp[m][n-1])
print(ans)


# Optimized solution
n = int(eval(input()))
a = list(map(int, input().split())) + [-1]

money = 1000
k = 0

for i in range(n):
    if a[i+1] > a[i]:
        k += money//a[i]
        money = money - a[i]*(money//a[i])
    elif a[i+1] <= a[i]:
        money += k*a[i]
        k = 0

print(money)
# Original solution
n = int(eval(input()))
a = list(map(int,input().split()))
m = 1000
stocks = 0
drops = [False]*(n-1)
for i in range(n-1):
    if a[i] > a[i+1]:
        drops[i] = True
for i in range(n-1):
    if drops[i]:
        m+=stocks*a[i]
        stocks = 0
    else:
        stocks+=m//a[i]
        m -= (m//a[i])*a[i]
print((m + stocks*a[-1]))

# Optimized solution
def main():
    N=int(eval(input()))
    A=list(map(int,input().split()))
    ans=1000
    stocks=0
    for i in range(N-1):
        if A[i]>A[i+1]:
            ans+=stocks*A[i]
            stocks=0
        else:
            stocks+=(ans//A[i])
            ans-=(ans//A[i])*A[i]
    print((ans+stocks*A[-1]))
if __name__=='__main__':
    main()
# Original solution
from collections import deque

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

stack = deque()

stack.appendleft((0, 1000, 0))
max_money = 1000

while stack:
    target = stack.popleft()

    day = target[0]
    money = target[1]
    stock = target[2]

    if day + 1 <= N:
        stack.appendleft((day + 1, money + stock * A[day], 0))
        stack.appendleft(
            (day + 1, money - (money // A[day]) * A[day], money // A[day]))
    else:
        if max_money < money:
            max_money = money

print(max_money)


# Optimized solution
N = int(eval(input()))
A = list([int(x) for x in input().split()])

money = 1000
stock = 0

for i in range(N-1):
    if A[i] <= A[i+1]:
        stock += money // A[i]
        money -= (money // A[i]) * A[i]
    else:
        money += A[i] * stock
        stock = 0

print((money + stock * A[N-1]))
# Original solution
n = int(eval(input()))
a = list(map(int, input().split()))

buy = [0] * n
sell = [0] * n

prev = 1000
for i in range(n - 1):
    if a[i+1] > a[i]:
        buy[i] += 1

    if a[i+1] < a[i]:
        sell[i] += 1

for i in range(n - 1, 0, -1):
    if a[i-1] < a[i]:
        buy[i-1] += 1

    if a[i-1] > a[i]:
        sell[i-1] += 1

kabu = 0
money = 1000
for i, e in enumerate(a):
    if buy[i] == 2:
        get = money // e
        kabu += get
        money -= get * e

    if sell[i] == 2:
        money += kabu * e
        kabu = 0

if kabu:
    money += a[-1] * kabu

print(money)


# Optimized solution
INF = 300

n = int(eval(input()))
a = [INF] + list(map(int, input().split())) + [-INF]

money = 1000
stock = 0
for e1, e2 in zip(a, a[1:]):
    if e1 < e2:
        buy = money // e1
        money -= buy * e1
        stock += buy
    else:
        money += stock * e1
        stock = 0

print(money)
# Original solution
N=int(eval(input()))
ls=[int(s) for s in input().split()]
money=1000
stock=0
for i in range(N-1):
  if ls[i]<ls[i+1]:
    while money>=ls[i]:
      money-=ls[i]
      stock+=1
  elif ls[i]>ls[i+1]:
    money+=ls[i]*stock
    stock=0
money+=ls[N-1]*stock

print(money)

# Optimized solution
N=int(eval(input()))
ls=[int(s) for s in input().split()]
money=1000
stock=0
for i in range(N-1):
  if ls[i]<ls[i+1]:
    s=money//ls[i]
    money-=s*ls[i]
    stock+=s
  elif ls[i]>ls[i+1]:
    money+=ls[i]*stock
    stock=0
money+=ls[N-1]*stock

print(money)
# Original solution
N = int(eval(input()))
A = list(map(int, input().split()))
M = 1000
S = 0
for i in range(N-1):
    if A[i] < A[i+1]:
        S = M // A[i]
        M = M % A[i] + S*A[i+1]
        S = 0
    else:
        pass
print(M)

# Optimized solution
# DP法でトライ
N = int(eval(input()))
A = list(map(int, input().split()))

# i 日目に、株の売却が終了した時点の所持金の最大値
dp = [0]*N
dp[0] = 1000

for i in range(1,N):
    for j in range(0,i):
        dp[i] = max(dp[i], dp[i-1],(dp[j]//A[j])*A[i]+dp[j]%A[j])

print((dp[-1]))
# Original solution
INF=10**30
N=int(eval(input()))
A=list(map(int,input().split()))
s=sum(A)
dp=[[-INF]*(s+1) for i in range(N+1)]
dp[0][0]=1000
for i in range(N):
    for j in range(s+1):
        if dp[i][j]==-INF:
            continue
        for x in range(j+1):
            dp[i+1][j-x]=max(dp[i+1][j-x],dp[i][j]+A[i]*x)
        for x in range(dp[i][j]//A[i]+1):
            dp[i+1][j+x]=max(dp[i+1][j+x],dp[i][j]-A[i]*x)
print((max(dp[N])))

# Optimized solution
N=int(eval(input()))
A=list(map(int,input().split()))
money=1000;kabu=0
i=0
while(i<N):
    j=i
    money,kabu=money-(money//A[i])*A[i],kabu+(money//A[i])
    while(j<N-1 and A[j]<=A[j+1]):
        j+=1
    money=money+kabu*A[j]
    kabu=0
    i=j+1
print(money)
# Original solution
def main():
    n = int(eval(input()))
    A = list(map(int, input().split()))
    ans = 1000
    t, p = [], []
    if A[0] < A[1]:
        t.append(0)
    for i in range(1, n - 1):
        if A[i - 1] >= A[i] < A[i + 1]:
            t.append(i)
        elif A[i - 1] <= A[i] > A[i + 1]:
            p.append(i)
    b = 0
    for i in range(n):
        if i in t:
            b += ans // A[i]
            ans %= A[i]
        if i in p:
            ans += b * A[i]
            b = 0
    if b > 0:
        ans += b * A[-1]
    print(ans)


if __name__ == '__main__':
    main()


# Optimized solution
def main():
    n = int(eval(input()))
    A = list(map(int, input().split()))
    ans, b = 1000, 0
    def buy(a):
        nonlocal b, ans
        b += ans // a
        ans %= a
    def sell(a):
        nonlocal b, ans
        ans += b * a
        b = 0
    if A[0] < A[1]: buy(A[0])
    for i in range(1, n - 1):
        if A[i - 1] >= A[i] < A[i + 1]:
            buy(A[i])
        elif A[i - 1] <= A[i] > A[i + 1]:
            sell(A[i])
        else:
            continue
    if b > 0:
        sell(A[-1])
    print(ans)

if __name__ == '__main__':
    main()
# Original solution
ni = lambda: int(eval(input()))
nm = lambda: list(map(int, input().split()))
nl = lambda: list(map(int, input().split()))

n = ni()
a = nl()

ans = 0
for i in range(2**n):
  mo = 1000
  st = 0
  for j in range(n):
    if ((i>>j) & 1):
      s = mo//a[j]
      st += s
      mo -=a[j]*s
    else:
      mo+=st*a[j]
      st = 0
  ans = max(ans, mo)
print(ans) 


# Optimized solution
ni = lambda: int(eval(input()))
nm = lambda: list(map(int, input().split()))
nl = lambda: list(map(int, input().split()))

n = ni()
a = nl()

dp=[0]*(n+1)
dp[0] = 1000

for i in range(1,n):
  dp[i]=dp[i-1]
  for j in range(i):
    v = dp[j] // a[j]
    w = dp[j] + (a[i]-a[j])*v
    dp[i] = max(dp[i],w)
print((dp[n-1]))
# Original solution
import sys
k=1000
N=int(eval(input()))
L=list(map(int,input().split()))
i=0
while i<N-1:
  if L[i]<L[i+1]:
    n=L[i]
    break
  i+=1
  if i==N-1:
    print((1000))
    sys.exit()
n=0
for j in range(i,N):
  if j==N-1 and n!=0:
    m=max(L[s:])
    c=k%n
    k=((k//n)*m)+c
    n=0
    break
  if j==N-1 and n==0:
    break
  if L[j]<L[j+1] and n==0:
    n=L[j]
    s=j
  if L[j]>L[j+1] and n!=0:
    m=L[j]
    c=k%n
    k=((k//n)*m)+c
    n=0
print(k)

# Optimized solution
n = int(eval(input()))
a = list(map(int, input().split()))
money = 1000
kabu = 0
for i in range(n-1):
    if a[i] < a[i+1] and money != 0:
        kabu += money // a[i]
        money -= a[i] *(money // a[i])
    elif a[i] > a[i+1] and kabu != 0:
        money += a[i] * kabu
        kabu = 0
print((money + a[-1] * kabu))
# Original solution
from collections import defaultdict

N = int(eval(input()))
A = list(map(int, input().split()))
d = defaultdict(lambda: 0)
d[0] = 1000

for i in range(N):
    dd = d.copy()
    for s,m in list(dd.items()):
        temp = m//A[i]
        for j in range(1,temp+1):
            if(d[s+j]<m-j*A[i]):
                d[s+j]=m-j*A[i]
        for j in range(1,s+1):
            if(d[s-j]<m+j*A[i]):
                d[s-j]=m+j*A[i]

print((d[0]))





# Optimized solution
N = int(eval(input()))
A = list(map(int, input().split()))
m=1000
s=0
for i in range(N-1):
    if A[i] < A[i+1]:
        s+=m//A[i]
        m=m%A[i]
    if A[i] > A[i+1]:
        m += A[i]*s
        s=0

print((m+A[N-1]*s))
# Original solution
#bottomかtopか
n=int(eval(input()))
a=list(map(int,input().split()))
an=[]
for i in range(1,n):
    if a[i]>a[i-1]:
        an.append(a[i-1])
        if i==n-1:
            an.append(a[i])
        break
pm=0
for j in range(i+1,n):
    #print(pm)
    if pm==0:
        if a[j]>=a[j-1]:
            if j==n-1:
                an.append(a[j])
            continue
        else:
            an.append(a[j-1])
            pm=1
    else:
        if a[j]<=a[j-1]:
            continue
        else:
            an.append(a[j-1])
            pm=0
            if j==n-1:
                an.append(a[j])
#print(an)
ans=1000
k=0
for i in range(len(an)):
    if i%2==0:
        k=ans//an[i]
        ans-=k*an[i]
    else:
        ans+=k*an[i]
        k=0
print(ans)

# Optimized solution
n=int(eval(input()))
a=list(map(int,input().split()))
dp=[0]*n
dp[0]=1000
for i in range(1,n):
    dp[i]=dp[i-1]
    for j in range(i):
        dp[i]=max(dp[i],(dp[j]//a[j])*a[i]+dp[j]%a[j])
print((dp[n-1]))
# Original solution
import collections
N=int(eval(input()))
A=list(map(int,input().split()))
i=0
A.insert(0,float("inf"))
#print(A)
buy=[0]*N
sell=[0]*N
for i in range(N-1):
    if (A[i]>=A[i+1])and(A[i+2]>=A[i+1]):
        buy[i]=1
    if (A[i]<=A[i+1])and(A[i+2]<=A[i+1]):
        sell[i]=1
kabu=0
money=1000
#print(buy,sell)
#print(money,kabu)
A=A[1:]
#print(A)
for i in range(N):
    if sell[i]==1:
        money=money+kabu*A[i]
        kabu=0
    if buy[i]==1:
        kabu=kabu+money//A[i]
        money=money-(money//A[i])*A[i]
    #print(money,kabu,A[i])
    #input()
#print(money,kabu)
money=money+kabu*A[N-1]
print(money)




# Optimized solution
import collections
N=int(eval(input()))
A=list(map(int,input().split()))
i=0
A.insert(0,float("inf"))
#print(A)
buy=[0]*N
sell=[0]*N
for i in range(N-1):
    if (A[i]>=A[i+1])and(A[i+2]>=A[i+1]):
        buy[i]=1
    if (A[i]<=A[i+1])and(A[i+2]<=A[i+1]):
        sell[i]=1
kabu=0
money=1000
#print(buy,sell)
#print(money,kabu)
A=A[1:]
#print(A)
for i in range(N):

    if buy[i]==1:
        kabu=kabu+money//A[i]
        money=money-(money//A[i])*A[i]

    if sell[i]==1:
        money=money+kabu*A[i]
        kabu=0

    #print(money,kabu,A[i])
    #input()
#print(money,kabu)
money=money+kabu*A[N-1]
print(money)
# Original solution
import sys
sys.setrecursionlimit(10**9)

def mi(): return list(map(int,input().split()))
def ii(): return int(eval(input()))
def isp(): return input().split()
def deb(text): print(("-------\n{}\n-------".format(text)))

INF=10**20
def main():
    N=ii()
    A=list(mi()) + [0]

    dp = [[0] * (2*10**5+10) for _ in range(N+1)]
    x = 1000//A[0]
    dp[0][x] = 1000 - x * A[0]


    for i in range(x):
        dp[0][i] = 1000 - i * A[0]

    mx = x
    for i in range(N):
        _mx = mx
        for m in range(mx+1):
            for n in range(m+1):
                dp[i+1][m-n] = max(0,dp[i+1][m-n],dp[i][m] + A[i+1] * n)
                # assert dp[i+1][m-n] >= 0
            
            if A[i+1] != 0:
                for j in range((dp[i][m] // A[i+1])+1):
                    dp[i+1][m+j] = max(0,dp[i+1][m+j],dp[i][m] - A[i+1] * j)
                    _mx = max(_mx,m+j)
                    
                    # assert dp[i+1][m+j] >= 0

        mx = _mx

    ans = 0
    for i in range(len(dp[N-1])):
        if dp[N-1][i] == 0: continue
        ans = max(ans, dp[N-1][i] + A[N-1] * i)

    # print(dp[3][10])
    print(ans)

if __name__ == "__main__":
    main()

# Optimized solution
import sys
sys.setrecursionlimit(10**9)

def mi(): return list(map(int,input().split()))
def ii(): return int(eval(input()))
def isp(): return input().split()
def deb(text): print(("-------\n{}\n-------".format(text)))

INF=10**20
def main():
    N=ii()
    _A=list(mi())
    A = []

    for a in _A:
        if len(A) > 0 and A[-1] == a: continue
        A.append(a)
    
    N = len(A)
    bottoms = []
    
    if N < 2:
        print((1000))
        exit()

    if A[0] < A[1]:
        bottoms.append(0)

    for i in range(N-1):
        if not i+2 < len(A): continue
        # print(A[i], A[i+1], A[i+2])
        if A[i] > A[i+1] and A[i+1] < A[i+2]:
            bottoms.append(i+1)
    
    money = 1000
    kabu = 0
    # print(bottoms)
    for bi in bottoms:
        bottom = A[bi]
        i = bi
        while i < N-1 and A[i] < A[i+1]:
            i += 1
        
        top = A[i]

        # print(bi,i)
        # print(bottom,top)
        kabu += money//bottom
        money -= money//bottom * bottom
        
        money += kabu * top
        kabu = 0
        # print("money",money)
    
    print(money)

    

if __name__ == "__main__":
    main()
# Original solution
#!/usr/bin/env python
n = int(eval(input()))
given_a = list(map(int, input().split()))

a = []
for k in given_a:
    if len(a) > 0 and a[-1] == k:
        continue
    else:
        a.append(k)

money = 1000
kabu = 0 

n = len(a)

if n == 1:
    print(money)
    exit()

for i in range(n):
    if i == 0:
        if a[i] > a[i+1]:
            continue
        else:
            kabu += money//a[i]
            money %= a[i]
    elif i == n-1:
        money += kabu*a[i]
        kabu = 0 
    else:
        if a[i] > a[i-1] and a[i] > a[i+1]:
            money += kabu*a[i]
            kabu = 0 
        elif a[i] < a[i-1] and a[i] < a[i+1]:
            kabu += money//a[i]
            money %= a[i]

print(money)


# Optimized solution
#!/usr/bin/env python
n = int(eval(input()))
a = list(map(int, input().split()))

money = 1000
kabu = 0 

for i in range(n-1):
    s = a[i]
    t = a[i+1]
    if s < t:
        k = money//s
        money %= s
        money += k*t 

print(money)
# Original solution
import sys

def solve():
    input = sys.stdin.readline
    I, O, T, J, L, S, Z = list(map(int, input().split()))
    #I * 2: 4; O * 1: 2, J, L * 2: 4, I + J + L: 6 
    Ans = O * 2
    six = min([I, J, L])
    Ans += six * 6
    I -= six
    J -= six
    L -= six
    Ans += 4 * (I // 2 + J // 2 + L // 2)
    rem = I % 2 + J % 2 + L % 2
    if six > 0 and rem == 2: Ans += 2
    print((Ans // 2))

    return 0

if __name__ == "__main__":
    solve()

# Optimized solution
import sys

def solve():
    input = sys.stdin.readline
    I, O, T, J, L, S, Z = list(map(int, input().split()))
    Ans = O
    six = min([I, J, L])
    Ans += 3 * six
    I -= six
    J -= six
    L -= six
    Ans += 2 * (I // 2 + J // 2 + L // 2)
    rem = I % 2 + J % 2 + L % 2
    if six > 0 and rem == 2: Ans += 1
    print(Ans)
    
    return 0

if __name__ == "__main__":
    solve()
# Original solution
i,o,t,j,l,s,z=list(map(int,input().split()))
a=(i//2+j//2+l//2)*2
print(([a,max(a,((i-1)//2+(j-1)//2+(l-1)//2)*2+3)][(i and j and l)>0]+o))

# Optimized solution
I,O,T,J,L,S,Z=list(map(int,input().split()))
print((max((~-I//2+~-J//2+~-L//2)*2+O+3*(I>0<L>0<J),(I//2+J//2+L//2)*2+O)))
# Original solution
I,O,T,J,L,S,Z=list(map(int,input().split()))
print((max((~-I//2+~-J//2+~-L//2)*2+O+3*(I>0<L>0<J),(I//2+J//2+L//2)*2+O)))

# Optimized solution
I,O,T,J,L,S,Z=list(map(int,input().split()))
print((max((~-I//2+~-J//2+~-L//2)*2+3*(I>0<L>0<J),I//2+J//2+L//2<<1)+O))
# Original solution
def popcount_parity(x):
    for i in range(8):
        x ^= x >> (1 << i)
    return -1 if x & 1 else 1

N, K, S, T = list(map(int, input().split()))
if S & T != S:
    print((0))
    exit()

C = [[1]]
CC = [0] * 51
for i in range(1, 51):
    C.append([1] * (i + 1))
    for j in range(1, i):
        C[i][j] = C[i-1][j-1] + C[i-1][j]
for i in range(51):
    CC[i] = sum(C[i][1:K+1])

A = [int(a) for a in input().split()]
aa, oo = - 1, 0
for i in range(N)[::-1]:
    a = A[i]
    if a & S != S or a | T != T:
        del A[i]
        continue
    aa &= a
    oo |= a
aa ^= oo

i = aa
ans = 0
while 1:
    D = {}
    for a in A:
        t = i & a
        if t not in D: D[t] = 1
        else: D[t] += 1
    ans += sum([CC[t] for t in list(D.values())]) * popcount_parity(i)
    if not i: break
    i = (i - 1) & aa
print(ans)

# Optimized solution
def popcount_parity(x):
    x ^= x >> 1
    x ^= x >> 2
    x ^= x >> 4
    x ^= x >> 8
    x ^= x >> 16
    return -1 if x & 1 else 1

N, K, S, T = list(map(int, input().split()))
if S & T != S:
    print((0))
    exit()

C = [[1]]
CC = [0] * 51
for i in range(1, 51):
    C.append([1] * (i + 1))
    for j in range(1, i):
        C[i][j] = C[i-1][j-1] + C[i-1][j]
for i in range(51):
    CC[i] = sum(C[i][1:K+1])

A = [int(a) for a in input().split()]
aa, oo = - 1, 0
for i in range(N)[::-1]:
    a = A[i]
    if a & S != S or a | T != T:
        del A[i]
        continue
    aa &= a
    oo |= a
aa ^= oo

i = aa
ans = 0
while 1:
    D = {}
    for a in A:
        t = i & a
        if t not in D: D[t] = 1
        else: D[t] += 1
    c = 0
    for t in list(D.values()):
        c += CC[t]
    ans += c * popcount_parity(i)
    if not i: break
    i = (i - 1) & aa
print(ans)
# Original solution
tmp = list(input().split())
H = int(tmp[0])
N = int(tmp[1])

tmp = list(input().split())
sum = 0

for i in range (N) :
    sum += int(tmp[i])

print(('Yes' if sum >= H else 'No'))

# Optimized solution
H,N= list(map(int,input().split()))
A=list(map(int,input().split()))

x=0

for i in range(N):
    x=x+A[i]

if x>=H:
    print("Yes")
else:
    print("No")
# Original solution
H,N= list(map(int,input().split()))
A=list(map(int,input().split()))

x=0

for i in range(N):
    x=x+A[i]

if x>=H:
    print("Yes")
else:
    print("No")

# Optimized solution
hn = list(map(int,input().split()))
h,n = hn
a = list(map(int,input().split()))
h -= sum(a)
if h > 0:
    print ("No")
else:
    print ("Yes")
# Original solution
h, n = list(map(int, input().split()))
a = [int(x) for x in input().split()]

h -= sum(a)

if h <= 0:
    print('Yes')
else:
    print('No')


# Optimized solution
def can_win_without_repeated_move(health, special_moves_damages) -> str:
    """
    Given a monster's health and a number of special moves with differ damages, 
    can we deplete the monster's health without repeating the same move twice?
    :param health: int
    :param special_moves_damages: list[int] 
    :return: str
    """
    return 'Yes' if health - sum(special_moves_damages) <= 0 else 'No'


if __name__ == '__main__':
    print((can_win_without_repeated_move(list(map(int, input().split()))[0], list(map(int, input().split())))))
# Original solution
h,n = list(map(int,input().split()))
A = list(map(int,input().split()))

print(('Yes' if sum(A)>=h else 'No'))


# Optimized solution
h,n=list(map(int,input().split()))
A=list(map(int,input().split()))
print(('Yes' if h<=sum(A) else 'No'))
# Original solution
H, N = [int(x) for x in input().split()]
attacks = [int(x) for x in input().split()]
print(("Yes" if H - sum(attacks) <= 0 else "No"))

# Optimized solution
H,N= list(map(int, input().split()))
AList = list(map(int,input().split()))
if sum(AList)>=H:
  print("Yes")
else:
  print("No")
# Original solution
import sys
input = sys.stdin.readline
H, N = list(map(int, input().split()))
a = list(map(int, input().split()))
if sum(a) >= H:
  print("Yes")
else: print("No")

# Optimized solution
import sys
input = sys.stdin.readline
H, N = list(map(int, input().split()))
sm = sum(list(map(int, input().split())))
if H <= sm: print("Yes")
else: print("No")
# Original solution
a,b=list(map(int,input().split()))
c=[int(x) for x in input().split()]
se=set()
import itertools
ok=False
for j in range(b):
    for i in itertools.permutations(c,r=j+1):
        if sum(i)>=a:
            ok=True
            break
    if ok:
        break
if ok:
    print("Yes")
else:
    print("No")

# Optimized solution
a,b=list(map(int,input().split()))
c=[int(x) for x in input().split()]

if sum(c)>=a:
    print("Yes")
else:
    print("No")
# Original solution
H, N = list(map(int, input().split()))
A = list(map(int, input().split()))
A.sort(reverse=True)
for i in range(N):
  H -= A[i]
print(("Yes" if H <= 0 else "No"))

# Optimized solution
H, N = list(map(int, input().split()))
A = [int(x) for x in input().split()]

print(("Yes" if H <= sum(A) else "No"))
# Original solution
H, N = list(map(int, input().split()))
A = [int(x) for x in input().split()]

print(("Yes" if H <= sum(A) else "No"))

# Optimized solution
h,n = list(map(int, input().split()))
A = list(map(int, input().split()))
print(("Yes" if sum(A)>=h else "No"))
# Original solution
data = [int(_) for _ in input().split()]
num = [int(_) for _ in input().split()]
if sum(num) < data[0]:
  print("No")
else:
  print("Yes")

# Optimized solution
data = [int(_) for _ in input().split()][0]
num = sum([int(_) for _ in input().split()])
if num < data:
  print("No")
else:
  print("Yes")
# Original solution
# モンスターの体力は H
# アライグマは N 種類の必殺技を使うことができ
# i番目の必殺技を使うとモンスターの体力を Ai 減らすことができます。
# モンスターの体力を0以下にすれば、アライグマ勝ち
# アライグマが同じ必殺技を 2 度以上使うことなくモンスターに勝つことができるなら Yes を、
# できないなら No を出力してください。

H, N = list(map(int, input().split()))
data = list(map(int, input().split()))

if H - sum(data) > 0:
    print('No')
else:
    print('Yes')


# Optimized solution
# モンスターの体力は H
# アライグマは N 種類の必殺技を使うことができ
# i番目の必殺技を使うとモンスターの体力を Ai 減らすことができます。
# モンスターの体力を0以下にすれば、アライグマ勝ち
# アライグマが同じ必殺技を 2 度以上使うことなくモンスターに勝つことができるなら Yes を、
# できないなら No を出力してください。

H, N = list(map(int, input().split()))
data = list(map(int, input().split()))
sum = sum(data)

if H - sum > 0:
    print('No')
else:
    print('Yes')
# Original solution
H,N = list(map(int,input().split()))
A = list(map(int,input().split()))

ans = "No"
sumA = 0
for a in A:
  sumA += a
  if sumA >= H:
    ans = "Yes"
    break
  
print(ans)

# Optimized solution
H,N = list(map(int,input().split()))
A = list(map(int,input().split()))

ans = "No"
if sum(A) >= H:
  ans = "Yes"
  
print(ans)
# Original solution
import sys
H,N=list(map(int,input().split()))
A = list(map(int,input().split()))

for i in range(N):
    m=max(A)
    H-=m
    if(H <= 0):
        print('Yes')
        sys.exit()
    A.remove(m)
print('No')


# Optimized solution
import sys
H,N=list(map(int,input().split()))
A = list(map(int,input().split()))

sortA=sorted(A)

for i in range(N):
    H-=sortA.pop()
    if(H <= 0):
        print('Yes')
        sys.exit()
print('No')