CodeEff/ECCO huggingface dataset:
# Original solution
import sys

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

money = 1000
min_price = float("inf")
for i in range(N):
    if min_price > A[i]:
        min_price = A[i]
    elif min_price < A[i]:
        num = money // min_price
        money = money - min_price * num + A[i] * num
        min_price = A[i]

print(money)

# Optimized solution
import sys

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

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

print(yen)
# Original solution
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return list(map(int, input().split()))
sys.setrecursionlimit(10**9)

N = int(eval(input()))
As = list(mapint())

memo = {}
s = set()

ans = 0
def dfs(idx, money, stocks):
    global ans
    if idx==N:
        ans = max(ans, money)
        return
    a = As[idx]
    if (idx, stocks) in s:
        if money<=memo[(idx, stocks)]:
            return
    s.add((idx, stocks))
    memo[(idx, stocks)] = money
    for num in range(1, stocks+1):
        dfs(idx+1, money+a*num, stocks-num)
    cnt = 0
    while money>=0:
        dfs(idx+1, money, stocks+cnt)
        cnt += 1
        money -= a

dfs(0, 1000, 0)
print(ans)

# Optimized solution
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return list(map(int, input().split()))
sys.setrecursionlimit(10**9)

N = int(eval(input()))
As = list(mapint())

memo = {}
s = set()

ans = 0
def dfs(idx, money, stocks):
    global ans
    if idx==N:
        ans = max(ans, money)
        return
    a = As[idx]
    if (idx, stocks) in s:
        if money<=memo[(idx, stocks)]:
            return
    s.add((idx, stocks))
    memo[(idx, stocks)] = money
    dfs(idx+1, money+stocks*a, 0)
    dfs(idx+1, money, stocks)
    cnt = money//a
    dfs(idx+1, money-cnt*a, stocks+cnt)

dfs(0, 1000, 0)
print(ans)
# Original solution

N = int(eval(input()))
X = 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):
        n = dp[j] // X[j]
        dp[i] = max(dp[i], dp[j] + (X[i] - X[j]) * n)

print((dp[-1]))


# Optimized solution

N = int(eval(input()))
X = list(map(int, input().split()))

cur = 1000
stock = 0
state = 0  # 1=increase, 0=decrease
for i in range(N - 1):
    if state == 1 and X[i] > X[i + 1]:
        cur += X[i] * stock
        stock = 0
        state = 0
    elif state == 0 and X[i] < X[i + 1]:
        n = cur // X[i]
        cur -= X[i] * n
        stock += n
        state = 1

print((cur + stock * X[-1]))
# Original solution
#!/usr/bin/env python3
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import collections
from decimal import Decimal # 10進数で考慮できる

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

d = collections.deque()
def LI(): return list(map(int, sys.stdin.readline().split()))

N = int(eval(input()))
A = LI()

tmp = 1000
stocks = 0
for i in range(N - 1):
    if A[i] < A[i + 1]: # 明日の方が高い　買う
        new_stocks = tmp // A[i]
        stocks += new_stocks
        tmp -= new_stocks * A[i]
    else:# 明日の方が安い　うる
        tmp += stocks * A[i]
        stocks = 0
tmp += stocks * A[-1]
print(tmp)



# Optimized solution
#!/usr/bin/env python3
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import collections
from decimal import Decimal # 10進数で考慮できる

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

d = collections.deque()
def LI(): return list(map(int, sys.stdin.readline().split()))

# N = int(input())
# A = LI()

# tmp = 1000
# stocks = 0
# for i in range(N - 1):
#     if A[i] < A[i + 1]: # 明日の方が高い　買う
#         new_stocks = tmp // A[i]
#         stocks += new_stocks
#         tmp -= new_stocks * A[i]
#     else:# 明日の方が安い　うる
#         tmp += stocks * A[i]
#         stocks = 0
# tmp += stocks * A[-1]
# print(tmp)

N = int(eval(input()))
A = LI()

cash = 1000
stocks = 0
for i in range(N - 1): 
    if A[i] < A[i + 1]: # 明日の方が高いなら買えるだけ買い
        buy_stocks = cash // A[i]
        stocks += buy_stocks
        cash -= buy_stocks * A[i]
    else: # 値段が同じor安いなら全ての株を現金化しておく
        cash += stocks * A[i]
        stocks = 0
cash += stocks * A[-1] # 最終日には全てを現金化する
print(cash)
# Original solution
N = int(eval(input()))
A = list(map(int, input().split()))

s = (1000, 0, 0)
mmax = 1000

q = []
q.append(s)
while len(q) > 0:
    m,k,d = q.pop()
    if d == N-1:
        m += k*A[d]
        if mmax < m:
            mmax = m
    elif d == N-2:
        if A[d] > A[d+1]:
            if k > 0:
                q.append((m+k*A[d], 0, d+1))
            else:
                q.append((m,k,d+1))
        else:
            nk,nm = k,m
            if k > 0:
                nm = m + k * A[d]
                nk = 0
            if nm > A[d]:
                x = nm //A[d]
                q.append((nm-x*A[d], nk+x, d+1))
            else:
                q.append((m,k,d+1))
    else:
        q.append((m,k,d+1))
        if m > A[d]:
            x = m // A[d]
            nm = m-x*A[d]
            nk = k+x
            q.append((nm,nk,d+1))
        if k > 0:
            nm = m+k*A[d]
            q.append((nm, 0, d+1))
            x = nm // A[d]
            if x > 0:
                q.append((nm - x*A[d], x, d+1))
print(mmax)  


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

m = 1000
k = 0
for i in range(N-1):
    if A[i] > A[i+1]:
        m += k * A[i]
        k = 0
    elif A[i] < A[i+1]:
        m += k * A[i]
        k = m // A[i]
        m -= k * A[i]
    else:
        pass
m += (k * A[-1])
print(m)
# Original solution
n=int(eval(input()))
a=[float('Inf')]
a+=list(map(int,input().split()))
i=0
m=1000
while i<n:
    if a[i]>a[i+1]:
        s=a[i+1]
    if a[i]<a[i+1]:
        m=m//s*a[i+1]+m%s
        s=a[i+1]
    i+=1
print(m)

# Optimized solution
n=int(eval(input()))
a=[float('inf')]
a+=list(map(int,input().split()))
d=[1000 for i in range(n+1)]
for i in range(1,n+1):
    d[i]=max(d[i-1],d[i-1]//a[i-1]*a[i]+d[i-1]%a[i-1])
print((d[-1]))
# Original solution
N = int(eval(input()))
A = list(map(int, input().split()))

memo = {}


def solve(i, j, k):
    if i == N - 1:
        return j + A[i] * k
    if (i, j, k) in memo:
        return memo[(i, j, k)]
    res = max(solve(i + 1, j, k),
              solve(i + 1, j % A[i], k + j // A[i]),
              solve(i + 1, j + A[i] * k, 0))
    memo[(i, j, k)] = res
    return res


print((solve(0, 1000, 0)))

# Optimized solution
N = int(eval(input()))
A = list(map(int, input().split()))
count = 0
money = 1000
kabu = 0
temp = A[0]
while count < N:
    if A[count] > temp:
        kabu = money // temp
        money = money % temp
        money += kabu * A[count]
        kabu = 0
    temp = A[count]
    count += 1

print(money)
# Original solution
import math
import collections
import fractions
import itertools
import functools
import operator
import bisect

def divis(l):
    seq = []
    beg, end = 0, 0
    le = len(l)
    for i in range(1,le):
        end = i
        if l[i] < l[i-1]:
            seq.append(l[beg:end])
            beg = i
    seq.append(l[beg:end+1])
    return seq

def solve():
    n = int(eval(input()))
    a = list(map(int, input().split()))
    divia = divis(a)
    saihu = 1000
    for i in divia:
        saihu += (i[-1]-i[0])*(saihu//i[0])
    print(saihu)
    return 0

if __name__ == "__main__":
    solve()

# Optimized solution
import math
import collections
import fractions
import itertools
import functools
import operator

def divis(l):
    seq = []
    beg, end = 0, 0
    le = len(l)
    for i in range(1,le):
        end = i
        if l[i] < l[i-1]:
            seq.append(l[beg:end])
            beg = i
    seq.append(l[beg:end+1])
    return seq

def solve():
    n = int(eval(input()))
    a = list(map(int, input().split()))
    a = divis(a)
    yosan = 1000
    for i in a:
        yosan += (i[-1]-i[0])*(yosan//i[0])
    print(yosan)
    return 0

if __name__ == "__main__":
    solve()
# Original solution
from sys import stdin
nii=lambda:list(map(int,stdin.readline().split()))
lnii=lambda:list(map(int,stdin.readline().split()))

n=int(eval(input()))
a=lnii()

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

money+=kabu*a[n-1]
print(money)

# Optimized solution
from sys import stdin
nii=lambda:list(map(int,stdin.readline().split()))
lnii=lambda:list(map(int,stdin.readline().split()))

n=int(eval(input()))
a=lnii()+[0]

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

print(money)
# Original solution
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり

N = I()
B = [0] + LI()

A = [0]
for i in range(N):  # 要らないものを消す
    if B[i] != B[i+1]:
        A.append(B[i+1])

N = len(A)-1
MAX = [0,1000] + [0]*N  # MAX[i] = i日目開始時点の所持金の最大値

from functools import lru_cache

@lru_cache(maxsize=None)
def dfs(n,money):
    if n == N+1:
        return money
    else:
        res = money
        for i in range(n,N):  # 購入
            for j in range(i+1,N+1):  # 売却
                if A[i] == min(A[i:j+1]) and A[j] == max(A[i:j+1]) and A[i] < A[j]:
                    a = money+(A[j]-A[i])*(money//A[i])
                    if a > MAX[j+1]:
                        res = max(res,dfs(j+1,a))
                        MAX[j+1] = a
        return res

print((dfs(1,1000)))


# Optimized solution
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり

N = I()
A = LI()

# 買った株は翌日全て売ってよい
# 貪欲に

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


# Optimized solution
n=int(eval(input()))
a=[int(i) for i in input().split()]
a.append(0)
x,y=1000,0
for i in range(n):
    if a[i]>a[i+1]:
        x+=y*a[i]
        y=0
    else:
        y+=x//a[i]
        x=x%a[i]
print((x+y*a[-2]))
# Original solution
n=int(eval(input()))
a=[int(i) for i in input().split()]
a.append(0)
x,y=1000,0
for i in range(n):
    if a[i]>a[i+1]:
        x+=y*a[i]
        y=0
    else:
        y+=x//a[i]
        x=x%a[i]
print((x+y*a[-2]))

# Optimized solution
n=int(eval(input()))
a=[int(i) for i in input().split()]
a.append(0)
x,y=1000,0
for i in range(n):
    if a[i]>=a[i+1]:
        x+=y*a[i]
        y=0
    else:
        y+=x//a[i]
        x=x%a[i]
print(x)
# Original solution
n = int(eval(input()))
a = list(map(int, input().split())) + [0]

buy, sell = [], []
for i in range(n):
    if a[i] < a[i+1] and len(buy) - len(sell) == 0:
        buy.append(i)
    if len(buy) - len(sell) == 1 and a[i] > a[i+1]:
        sell.append(i)

cash = 1000
for i, j in zip(buy, sell):
    stock, rest = divmod(cash, a[i])
    cash = stock * a[j] + rest

print(cash)

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

cash = 1000

for buy, sell in zip(a, a[1:]):
    if buy >= sell:
        continue
    stock, cash = divmod(cash, buy)
    cash += stock * sell

print(cash)
# Original solution
n,*l=list(map(int,open(0).read().split()))
a,c=1000,0
for i in range(n-1):
  s,t=l[i:i+2]
  if s>t: a+=c*s; c=0
  if s<t: c+=a//s; a-=a//s*s
print((a+c*t))

# Optimized solution
n,*l=list(map(int,open(0).read().split()))
a=1000
for i in range(n-1):
  s,t=l[i:i+2]
  a+=a//s*max(t-s,0)
print(a)
# Original solution
n = int(eval(input()))
a = list(map(int, input().split()))

pairs = []
low = None
if a[0] < a[1]:
	low = a[0]

for i in range(1, n):
	if a[i-1] > a[i]:
		if low is not None:
			pairs.append((low, a[i-1]))
			low = a[i]
	if a[i-1] < a[i]:
		if low is None:
			low = a[i-1]
if low is not None and low < a[n-1]:
	pairs.append((low, a[n-1]))

yen = 1000
for (l, h) in pairs:
	size = yen // l
	yen -= size * l
	yen += size * h
print(yen)

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

yen = 1000
for i in range(1, n):
	if a[i-1] < a[i]:
		stock = yen // a[i-1]
		yen -= stock * a[i-1]
		yen += stock * a[i]

print(yen)
# Original solution
import sys
sys.setrecursionlimit(4100000)

N = int(eval(input()))
A = list(map(int, input().split()))
pricelist = []


def dfs(day, money,stock):
    if day == N:
        pricelist.append(money+ stock * A[N-1])
        return
    price = A[day-1]
    dfs(day+1, money % price, stock + money//price)
    dfs(day+1, money, stock)
    dfs(day+1, money + stock * price, 0)
    return

dfs(1,1000,0)

print((max(pricelist)))




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

print(money)
# Original solution
n = int(eval(input()))
a = list(map(int, input().split()))

# 貪欲法
# a[i] < a[i+1]なら全部買う
# a[i] > a[i+1]なら全部売る

money = 1000
stock = 0
for i in range(n):
    if i == n-1 or a[i] > a[i+1]:
        money += stock * a[i]
        stock = 0
    elif money > a[i]:
        stock = money // a[i]
        money = money % a[i]

print(money)

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

# DP
# dp[i]: i日目の所持金の最大値（持ち株は売る）
dp = [0] * n
dp[0] = 1000

# dp[1] = 0日目に全部買って1日目に全部売る or 0日目から何もしない
# dp[2] = 0 or 1日目に全部買って2日目に全部売る or 1日目から何もしない
# dp[i+1] + 0~i日目のどこかで全部買ってi+1日目に全部売る or i日目から何もしない
for i in range(n):
    if i == 0:
        dp[i] = 1000
        continue
    
    dp[i] = dp[i-1]
    for j in range(i):
        # j日目に全部買ってi日目に全部売る
        dp[i] = max(dp[i], (dp[j] // a[j]) * a[i] + dp[j] % a[j])
    
print((dp[n-1]))
# Original solution
# coding: utf-8


def solve(*args: str) -> str:
    n = int(args[0])
    A = list(map(int, args[1].split()))
    budget = 1000
    stock = 0
    temp = 0

    for i in range(n-1):
        if A[i] < A[i+1] and A[i] <= temp+budget:
            budget += temp
            temp = 0
            stock = budget//A[i]
            budget %= A[i]
        elif A[i+1] < A[i]:
            budget += A[i]*stock
            stock = 0

    return str(A[-1]*stock+budget)


if __name__ == "__main__":
    print((solve(*(open(0).read().splitlines()))))


# Optimized solution
# coding: utf-8


def solve(*args: str) -> str:
    n = int(args[0])
    A = list(map(int, args[1].split()))
    budget = 1000
    stock = 0

    for i in range(n-1):
        if A[i] < A[i+1] and A[i] <= budget:
            stock, budget = divmod(budget, A[i])
        elif A[i+1] < A[i]:
            budget += A[i]*stock
            stock = 0

    return str(A[-1]*stock+budget)


if __name__ == "__main__":
    print((solve(*(open(0).read().splitlines()))))
# Original solution
def main():

    n = int(eval(input()))
    A = list(map(int, input().split()))
    INF = 19**18

    X = []
    Y = []
    A = [INF] + A
    for i in range(1, n):
        if len(X) == len(Y):
            if A[i-1] >= A[i] and A[i] < A[i+1]:
                X.append(i)
        if len(X) > len(Y):
            if  A[i-1] <= A[i] and A[i] > A[i+1]:
                Y.append(i)
    else:
        if len(X) > len(Y):
            Y.append(i+1)
    #print(X)
    #print(Y)

    cur = 1000
    for i, j in zip(X, Y):
        q, cur = divmod(cur, A[i])
        cur += q*A[j]
    print(cur)



if __name__ == '__main__':
    main()


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

x = 1000
for i in range(n-1):
    if A[i] < A[i+1]:
        q, x = divmod(x, A[i])
        x += q*A[i+1]
print(x)
# Original 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):
        V = dp[j] // A[j]
        W = dp[j] + (A[i] - A[j]) * V
        dp[i] = max(dp[i], W)

print((dp[N - 1]))

# Optimized solution
N = int(eval(input()))
A = list(map(int,input().split()))
ans = 1000

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

print(ans)
# Original solution
import sys
N=int(eval(input()))
alist=list(map(int,input().split()))

a2list=[alist[0]]
for i in range(1,N):
  if a2list[-1]!=alist[i]:
    a2list.append(alist[i])
#print(a2list)

N2=len(a2list)
if N2==1:
  print((1000))
  sys.exit(0)

yama_list=[False]*N2
tani_list=[False]*N2
if a2list[0]>a2list[1]:
  yama_list[0]=True
if a2list[0]<a2list[1]:
  tani_list[0]=True

for i in range(1,N2-1):
  if a2list[i-1]<a2list[i]>a2list[i+1]:
    yama_list[i]=True
  if a2list[i-1]>a2list[i]<a2list[i+1]:
    tani_list[i]=True
    
if a2list[N2-2]<a2list[N2-1]:
  yama_list[N2-1]=True
if a2list[N2-2]>a2list[N2-1]:
  tani_list[N2-1]=True
    
#print(yama_list)
#print(tani_list)

money=1000
kabu=0
for i in range(N2):
  if yama_list[i]:
    #sell all
    money+=a2list[i]*kabu
    kabu=0
  if tani_list[i] and i<N2-1:
    #buy as possible
    k=money//a2list[i]
    kabu+=k
    money-=k*a2list[i]
    
print(money)

# Optimized solution
N=int(eval(input()))
alist=list(map(int,input().split()))

money=1000
kabu=0
for i in range(N-1):
  if alist[i]<alist[i+1]:
    #buy as possible
    k=money//alist[i]
    kabu+=k
    money-=k*alist[i]
  elif alist[i]>alist[i+1]:
    #sell all
    money+=alist[i]*kabu
    kabu=0

money+=alist[N-1]*kabu    
print(money)
# Original solution
import itertools
#n, k = map(int,input().split())
n = int(eval(input()))
al = list(map(int,input().split()))

ans = 0
for v in itertools.product(list(range(2)),repeat=n):
    money = 1000
    kabu = 0

    for i in range(n):
        if v[i] == 0:
            kabu += money // al[i]
            money = money % al[i]
        elif v[i] == 1:
            money += kabu * al[i]
            kabu = 0
        else:
            continue
    ans = max(ans, money)
print(ans)


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

kabu = 0
money = 1000
for i in range(n-1):
    if al[i] < al[i+1]:
        # 全部売る
        money += kabu * al[i]
        kabu = 0
        # 全部買う
        kabu += money // al[i]
        money = money % al[i]
    else:
        # 全部売る
        money += kabu * al[i]
        kabu = 0

print((money+ kabu*al[-1]))
# Original solution
N = int(eval(input()))
A = list(map(int,input().split()))+[0]
kane = 1000
kabu = 0

baibai = [] 
#1は買い時、-1は売り時、0は無視
for i in range(N):
    sa = A[i+1] -A[i]
    if sa == 0:
        baibai.append(0)
    elif sa != abs(sa):
        baibai.append(-1)
    else:
        baibai.append(1)

#最後の売り時
if 1 in baibai:
    uri = N - (baibai[::-1].index(1))
else:
    uri = -1

#baibai通りに売買(最後の売り時で打ち切り)
for j in range(N):
    if j == uri:
        kane += A[j] * kabu
        print(kane)
        exit()
    elif baibai[j] > 0:
        kabu += (kane//A[j])
        kane -= A[j] * (kane//A[j])
    elif baibai[j] < 0:
        kane += A[j] * kabu
        kabu = 0

print(kane)

# Optimized solution
N = int(eval(input()))
A = list(map(int,input().split()))+[0]
kane = 1000
kabu = 0

baibai = [] 
#1は買い時、-1は売り時、0は無視
for i in range(N):
    sa = A[i+1] -A[i]
    if sa == 0:
        baibai.append(0)
    elif sa != abs(sa):
        baibai.append(-1)
    else:
        baibai.append(1)


#baibai通りに売買(最後の売り時で打ち切り)
for j in range(N):
    if baibai[j] > 0:
        kabu += (kane//A[j])
        kane -= A[j] * (kane//A[j])
    elif baibai[j] < 0:
        kane += A[j] * kabu
        kabu = 0

print(kane)
# Original solution
n=int(input())
a=list(map(int,input().split()))
b=[a[0]]
f=-1
for i in a:
  if b[-1]<i:
    if f==1:b[-1]=i
    else:
      b.append(i)
      f=1
  if b[-1]>i:
    if f==-1:b[-1]=i
    else:
      b.append(i)
      f=-1
if f==-1:del b[-1]
if len(b)==0:exit(print(1000))
now=1000
for i in range(0,len(b),2):
  bb=now//b[i]
  now-=bb*b[i]
  now+=bb*b[i+1]
print(now)


# Optimized solution
n=int(input())
a=list(map(int,input().split()))
b=[a[0]]
f=-1
for i in a:
  if b[-1]<i:
    if f==1:b[-1]=i
    else:
      b.append(i)
      f=1
  if b[-1]>i:
    if f==-1:b[-1]=i
    else:
      b.append(i)
      f=-1
if f==-1:del b[-1]
if len(b)==0:exit(print(1000))
ans=1000
for i in range(0,len(b),2):
  bb=ans//b[i]
  ans-=bb*b[i]
  ans+=bb*b[i+1]
print(ans)
# Original solution
n, *a = list(map(int, open(0).read().split()))
max_a = max(a)
money = 1000
stock = 0
for i in range(n-1):
    if a[i] < a[i+1]:
        stock = money // a[i]
        money += (a[i+1] - a[i]) * stock
print(money)

# Optimized solution
n, *a = list(map(int, open(0).read().split()))
money = 1000
stock = 0
for i in range(n-1):
    if a[i] < a[i+1]:
        stock = money // a[i]
        money += (a[i+1] - a[i]) * stock
print(money)
# Original solution
n= int(eval(input()))
arr = [int(x) for x in input().strip().split()]

mem = {}
def helper(i, mon, stk):
    key = (i, mon, stk)
    if key in mem:
        return mem[key]
    
    if i==len(arr):
        return mon
    
    ans = helper(i+1, mon, stk)
    buy = 1
    while True:
        if arr[i]*buy<=mon:
            ans = max(ans, helper(i+1, mon - arr[i]*buy, stk+buy))
        else:
            break
        
        buy += 1
    
    for s in range(1, stk+1):
        ans = max(ans, helper(i+1, mon+arr[i]*s, stk-s))
    
    mem[key] = ans
    return ans

    
print((helper(0, 1000, 0)))

# Optimized solution
n= int(eval(input()))
arr = [int(x) for x in input().strip().split()]


def Greedy(arr):
    
    curr = 1000
    for i in range(len(arr)-1):
        if arr[i+1]>arr[i]:
            stocks = curr // arr[i]
            curr += (arr[i+1] - arr[i])*stocks
    return curr

print((Greedy(arr)))

        
# mem = {}
# def helper(i, mon, stk):
#     key = (i, mon, stk)
#     if key in mem:
#         return mem[key]
    
#     if i==len(arr):
#         return mon
    
#     ans = helper(i+1, mon, stk)
#     buy = 1
#     while True:
#         if arr[i]*buy<=mon:
#             ans = max(ans, helper(i+1, mon - arr[i]*buy, stk+buy))
#         else:
#             break
        
#         buy += 1
    
#     for s in range(1, stk+1):
#         ans = max(ans, helper(i+1, mon+arr[i]*s, stk-s))
    
#     mem[key] = ans
#     return ans

    
# print(helper(0, 1000, 0))
# Original solution
def main():
    n = int(eval(input()))
    A = [int(x) for x in input().split()]
    money = 1000
    kabu_c = 0
    l = list()
    for i in range(n-1):
        if A[i+1] - A[i] > 0:
            l.append(1)
        else:
            l.append(0)
    for idx, i in enumerate(l):
        if i == 1:
            while  money - A[idx] >= 0:
                money = money - A[idx]
                kabu_c += 1
        if i == 0:
            money = money + (kabu_c * A[idx])
            kabu_c = 0
    if kabu_c > 0:
        money = money + (kabu_c * A[n-1])
    print(money)

if __name__ == '__main__':
    main()

# Optimized solution
def main():
    n = int(eval(input()))
    A = [int(x) for x in input().split()]
    money = 1000
    kabu_c = 0
    l = list()
    for i in range(n-1):
        if A[i+1] - A[i] > 0:
            l.append(1)
        else:
            l.append(0)
    for idx, i in enumerate(l):
        if i == 1 and money - A[idx] >= 0:
            kabu_c = money // A[idx]
            money = money - (kabu_c * A[idx])
        if i == 0:
            money = money + (kabu_c * A[idx])
            kabu_c = 0
    if kabu_c > 0:
        money = money + (kabu_c * A[n-1])
    print(money)

if __name__ == '__main__':
    main()