Problem:
 Score: 400 points    Problem Statement  To become a millionaire, M-kun has decided to make money by trading in the next N days. Currently, he has 1000 yen and no stocks - only one kind of stock is issued in the country where he lives.  He is famous across the country for his ability to foresee the future. He already knows that the price of one stock in the next N days will be as follows:   A_1 yen on the 1 -st day, A_2 yen on the 2 -nd day, ..., A_N yen on the N -th day.   In the i -th day, M-kun can make the following trade any number of times (possibly zero), within the amount of money and stocks that he has at the time .   Buy stock: Pay A_i yen and receive one stock.  Sell stock: Sell one stock for A_i yen.   What is the maximum possible amount of money that M-kun can have in the end by trading optimally?      Constraints   2 \leq N \leq 80  100 \leq A_i \leq 200  All values in input are integers.         Input  Input is given from Standard Input in the following format:  N  A_1  A_2  \cdots  A_N       Output  Print the maximum possible amount of money that M-kun can have in the end, as an integer.        Sample Input 1 7
100 130 130 130 115 115 150      Sample Output 1 1685  In this sample input, M-kun has seven days of trading. One way to have 1685 yen in the end is as follows:   Initially, he has 1000 yen and no stocks.  Day 1 : Buy 10 stocks for 1000 yen. Now he has 0 yen.  Day 2 : Sell 7 stocks for 910 yen. Now he has 910 yen.  Day 3 : Sell 3 stocks for 390 yen. Now he has 1300 yen.  Day 4 : Do nothing.  Day 5 : Buy 1 stock for 115 yen. Now he has 1185 yen.  Day 6 : Buy 10 stocks for 1150 yen. Now he has 35 yen.  Day 7 : Sell 11 stocks for 1650 yen. Now he has 1685 yen.   There is no way to have 1686 yen or more in the end, so the answer is 1685 .       Sample Input 2 6
200 180 160 140 120 100      Sample Output 2 1000  In this sample input, it is optimal to do nothing throughout the six days, after which we will have 1000 yen.       Sample Input 3 2
157 193      Sample Output 3 1216  In this sample input, it is optimal to buy 6 stocks in Day 1 and sell them in Day 2 , after which we will have 1216 yen.

Solution (Python):
import sys

readline = sys.stdin.readline
readall = sys.stdin.read
ns = lambda: readline().rstrip()
ni = lambda: int(readline().rstrip())
nm = lambda: map(int, readline().split())
nl = lambda: list(map(int, readline().split()))
prn = lambda x: print(*x, sep='\n')

def solve():
    n = ni()
    a = nl()
    g = [1000] * (n+1)
    for i in range(n):
        g[i+1] = max(g[i], max(g[j+1]//a[j]*a[i] + g[j+1]%a[j] for j in range(i+1)))
    print(g[-1])
    return

solve()

Solution (Python):
n = int(input())
a = list(map(int,input().split()))
now = 1000
st = 0
for i in range(n-1):
  if a[i] < a[i+1]:
    tmp = now // a[i]
    now %= a[i]
    st += tmp
  else:
    now += st * a[i]
    st = 0
  
print(now + a[-1] * st)

Solution (Python):
n = int(input())
a = list(map(int,input().split()))
m = 1000
temp = 0
for i in range(n-1):
    if a[i+1] < a[i]:
        m+=temp*a[i]
        temp = 0
    else:
        temp += m//a[i]
        m%=a[i]
m+=temp*a[-1]
print(m)

Solution (Python):
n=int(input())
a=list(map(int,input().split()))
money=1000
stock=0
for i in range(n-1):
  if a[i]>a[i+1]:
    money+=stock*a[i]
    stock=0
  else:
    stock+=money//a[i]
    money=money%a[i]
print(money+stock*a[n-1])

Solution (Python):
n = int(input())
money = 1000
a = list(map(int,input().split()))
for i in range(n-1):
	if a[i] < a[i+1]:
		targ = money//a[i]
		money += targ * (a[i+1] - a[i])
print(money)

Solution (Python):
def examA():
    X = I()
    X -= 400
    ans = 8 - X//200
    print(ans)
    return

def examB():
    A, B, C = LI()
    K = I()
    cnt = 0
    while(A>=B):
        B *= 2
        cnt += 1
    while(B>=C):
        C *= 2
        cnt += 1

    if cnt<=K:
        print("Yes")
    else:
        print("No")
    return

def examC():
    N, K = LI()
    A = LI()
    ans = ["Yes"]*(N-K)
    for i in range(N-K):
        if A[i+K]<=A[i]:
            ans[i] = "No"
    for v in ans:
        print(v)
    return

def examD():
    N = I()
    A = LI()
    l = A[0]
    cnt = 1000
    for a in A[1:]:
        if l<a:
            cnt += cnt//l * (a-l)
            l = a
        elif l>a:
            l = a
    ans = cnt
    print(ans)
    return

def examE():
    ans = 0
    print(ans)
    return

def examF():
    ans = 0
    print(ans)
    return

from decimal import getcontext,Decimal as dec
import sys,bisect,itertools,heapq,math,random
from copy import deepcopy
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
def I(): return int(input())
def LI(): return list(map(int,sys.stdin.readline().split()))
def DI(): return dec(input())
def LDI(): return list(map(dec,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,_ep
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
_ep = dec("0.000000000001")
alphabet = [chr(ord('a') + i) for i in range(26)]
alphabet_convert = {chr(ord('a') + i): i for i in range(26)}

getcontext().prec = 28

sys.setrecursionlimit(10**7)

if __name__ == '__main__':
    examD()

"""
142
12 9 1445 0 1
asd dfg hj o o
aidn
"""

Solution (Python):
def main():
    n = int(input())
    a = list(map(int, input().split()))
    c = 0
    m = 1000
    for i in range(n-1):
        if a[i] < a[i+1]:
            c += m//a[i]
            m -= (m//a[i])*a[i]
        elif a[i] > a[i+1]:
            m += a[i]*c
            c = 0
    m += a[n-1]*c
    print(m)


main()

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

X=1000
Y=0

for k in range(N-1):
    if Y:
        X+=Y*A[k]
        Y=0
        
    if A[k]<A[k+1]:
        Y=X//A[k]
        X-=A[k]*Y

X+=A[-1]*Y
print(X)

Solution (Python):

from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
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():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
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 solve():
    n = I()
    a = LI()
    ans = 1000
    for i in range(n-1):
        if a[i] < a[i+1]:
            k = ans//a[i]
            ans -= k*a[i]
            ans += k*a[i+1]
    print(ans)
    return


if __name__ == "__main__":
    solve()

Solution (Python):


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

money = 1000
stock = 0

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

print(money)

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

flag = 0
ans = 1000
cnt = 0
for i in range(n-1):
    if flag == 0 and A[i] < A[i+1]:
        cnt += ans//A[i]
        ans %= A[i]
        flag = 1
    elif flag == 1 and A[i] > A[i+1]:
        ans += cnt*A[i]
        cnt = 0
        flag = 0
print(ans + cnt*A[n-1])

Solution (Python):

N = int(input())

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

dp = [1000]

for i in range(N):

    now = dp[-1]
    for j in range(i):

        now = max(now , dp[j] % A[j] + dp[j]//A[j]*A[i])

    dp.append(now)

print (dp[-1])

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

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

money = 1000
maxm = 1000
kabu = 0
down = True 

for i in range(len(A) - 1):
  if down: 
    if A[i] < A[i + 1]: 
      kabu += money // A[i]
      money -= kabu * A[i]
      down = False
  else: 
    if A[i] > A[i + 1]: 
      money += kabu * A[i]
      kabu = 0
      if money > maxm:
        maxm = money
      down = True
      
if kabu > 0: 
  money += kabu * A[-1]
  
if money > maxm:
  maxm = money
  
print(maxm)

Solution (Python):
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, *A = map(int, read().split())

    ans = 1000
    for i in range(N - 1):
        if A[i] < A[i + 1]:
            n = ans // A[i]
            ans = ans + (A[i + 1] - A[i]) * n

    print(ans)

    return


if __name__ == '__main__':
    main()

Solution (Python):
n = int(input())
lis = list(map(int,input().split()))
ans = 1000
for i in range(n-1):
    if lis[i] < lis[i+1]:
        num = ans//lis[i]
        ans %= lis[i]
        ans += num * lis[i+1]
print(ans)

Solution (Python):
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N, *A = map(int, read().split())

kabu, yen = 0, 1000

for x, y in zip(A, A[1:] + [0]):
    
    kabu, yen = 0, yen + x * kabu
    if x < y:
        
        kabu, yen = divmod(yen, x)

print(yen)

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

m = 1000

for a,b in zip(A,A[1:]):
    if a >= b: continue
    k,m = divmod(m,a)
    m += k*b
print(m)

Solution (Python):
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


n = int(input())
a = list(map(int, input().split()))
val = 1000
prv = a[0]
for i in range(1,n):
    c = a[i]
    if c>prv:
        val = val + (val//prv)*c - (val//prv)*prv
    prv = c

print(val)

Solution (Python):
N=int(input())
A=list(map(int,input().split()))
DP=[[1000,1000,0] for i in range(N+1)]
for i in range(N):
  DP[i+1][0]=max(DP[i][0],DP[i][1]+DP[i][2]*A[i])
  DP[i+1][1]=DP[i+1][0]%A[i]
  DP[i+1][2]=DP[i+1][0]//A[i]
print(DP[N][0])

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

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

DP=[1000]*(N)

for i in range(N):
    DP[i]=max(DP[i-1],DP[i])
    st,rest=divmod(DP[i],A[i])

    
    for j in range(i+1,N):
        DP[j]=max(DP[j],st*A[j]+rest)

print(DP[-1])