CodeEff/ECCO huggingface dataset:
# Original solution
N = int(eval(input()))
A = list(map(int, input().split()))
syoji = 1000
kabu = 0
kai = 0
uri = 0
if N ==1:
  print(syoji)
  exit()
sw = 0
for i in range(N):
  if i<N-1 and kabu == 0 and A[i] < A [i+1]:
    for j in range(i+1,N):
      if sw ==1 and uri >= A[j]:
        break

      elif  A[i] < A[j]:
        uri = A[j]
        sw = 1

    if sw ==1:
      for num in range (1000000000):
        if syoji < num*A[i]:
          kabu = num-1
          syoji = syoji - (num-1)*A[i]
          kai = A[i]
          sw = 0
          break
  elif kabu > 0 and A[i]==uri:
    syoji = syoji + kabu*A[i]
    kabu = 0
    uri = 0

        
print(syoji)


# Optimized solution
N = int(eval(input()))
A = list(map(int, input().split()))
syoji = 1000
kabu = 0
kai = 0
uri = 0
if N ==1:
  print(syoji)
  exit()
sw = 0
for i in range(N):
  if i<N-1 and kabu == 0 and A[i] < A [i+1]:
    for j in range(i+1,N):
      if sw ==1 and uri >= A[j]:
        break
 
      elif  A[i] < A[j]:
        uri = A[j]
        sw = 1
    if sw ==1:
      kabu = syoji // A[i]
      syoji = syoji - kabu*A[i]
      kai = A[i]
      sw = 0
  elif kabu > 0 and A[i]==uri:
    syoji = syoji + kabu*A[i]
    kabu = 0
    uri = 0
 
        
print(syoji)
# Original solution
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    n = int(readline())
    a = list(map(int, readline().split()))
    money = 1000
    stock = 0

    day = 0

    while day < n - 1:
        if stock == 0:
            cur = a[day]
            buy_day = day
            for i in range(day + 1, n):
                if cur >= a[i]:
                    cur = a[i]
                else:
                    buy_day = i - 1
                    break
            else:
                break
            stock += money // a[buy_day]
            money -= a[buy_day] * stock
            day = buy_day
        else:
            sell_day = 0
            cur = a[day]
            for i in range(day + 1, n):
                if cur <= a[i]:
                    cur = a[i]
                else:
                    sell_day = i - 1
                    break
            else:
                sell_day = n - 1
            money += a[sell_day] * stock
            stock = 0
            day = sell_day

    print(money)


if __name__ == '__main__':
    main()


# Optimized solution
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    n = int(readline())
    a = [0] + list(map(int, readline().split()))
    dp = [0] * (n + 1)
    dp[0] = 1000

    for i in range(1, n + 1):
        dp[i] = dp[i - 1]
        for j in range(1, i):
            s = dp[j] // a[j]
            m = s * a[i] + dp[j] % a[j]
            dp[i] = max(dp[i], m)

    print((dp[n]))


if __name__ == '__main__':
    main()
# Original solution
from sys import stdin
input = stdin.readline

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

start = 0
money = 1000

for i in range(N - 1):
    if A[i + 1] > A[i]:
        tmp = 10 ** 3
        for k in range(i, start - 1, -1):
            tmp = min(A[k], tmp)
        buy = money // tmp
        money -= tmp * buy
        money += buy * A[i + 1]
        start = i + 1

print(money)


# Optimized solution
from sys import stdin
input = stdin.readline

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

start = 0
money = 1000

for i in range(N - 1):
    if A[i + 1] > A[i]:
        buy = money // A[i]
        money -= A[i] * buy
        money += buy * A[i + 1]

print(money)
# Original solution
n = int(eval(input()))
A = list(map(int, input().split()))
ans = 1000
for ii in range(2 ** n):
    tmp = 1000
    kab = 0
    action = 'buy'
    for i in range(n):
        if (ii >> i) & 1:
            if action == 'buy':
                if tmp < A[i]:
                    break
                kab += tmp // A[i]
                tmp = tmp % A[i]
                action = 'sell'

            elif action == 'sell':
                if kab == 0:
                    break
                tmp += kab * A[i]
                kab = 0
                action = 'buy'
    else:
        ans = max(ans, tmp)

print(ans)


# 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
n = int(eval(input()))
a = list(map(int, input().split()))

cur_m = 1000
cur_s = 0

state = -1 # 1:up 0:down
prev = 0
for ai in a:
  if state == -1:
    prev = ai
    state = 0
  elif state == 1:
    if prev > ai: # peak
      # sell at prev
      cur_m += (prev * cur_s)
      cur_s = 0
      state = 0
  else:
    if prev <= ai:
      # buy at prev
      while cur_m >= prev:
        cur_s += 1
        cur_m -= prev
      state = 1
  prev = ai

if cur_s > 0:
  cur_m += (a[-1] * cur_s)

print(cur_m)





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

cur_m = 1000
cur_s = 0

state = -1 # 1:up 0:down
prev = 0
for ai in a:
  if state == -1:
    prev = ai
    state = 0
  elif state == 1:
    if prev > ai: # peak
      # sell at prev
      cur_m += (prev * cur_s)
      cur_s = 0
      state = 0
  else:
    if prev < ai:
      # buy at prev
      buy_num = cur_m // prev
      cur_s += buy_num
      cur_m -= prev * buy_num
      state = 1
  prev = ai

if cur_s > 0:
  cur_m += (a[-1] * cur_s)

print(cur_m)
# Original solution
import sys
sys.setrecursionlimit(10**6)

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

ans = 1000

def dfs(money, share, day):
    global ans
    if day > n:
        ans = max(ans, money)
        return
    max_buy = money//A[day-1]
    max_sel = share
#    for n_buy in range(-max_sel, max_buy+1):
#        dfs(money-n_buy*A[day-1], share+n_buy, day+1)
    for n_buy in [-max_sel, 0, max_buy]:
        dfs(money-n_buy*A[day-1], share+n_buy, day+1)

dfs(1000,0,1)

print(ans)

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

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

CurrentMoney = 1000

for i in range(0, n-1):
    Stocks = 0
    if A[i] < A[i+1]: Stocks = CurrentMoney // A[i]
    CurrentMoney += (A[i+1] - A[i]) * Stocks

print(CurrentMoney)
# Original solution
N = int(eval(input()))
A = list(map(int,input().split()))

money=1000
best = money
pos = 1
kabu = 0

#初動 買うか買わないか
if A[0]<=A[1]:
    kabu = money//A[0]
    money -= kabu*A[0]
    pos=0
else:
    pos=1

#二回目以降　買うか売るか保留か
for i in range(1,N):
    if pos==0:#売り
        if A[i-1]>=A[i]:
            money+=kabu*A[i-1]
            kabu=0
            pos=1
    elif pos==1:#買い
        if A[i-1]<A[i]:
            kabu = money//A[i-1]
            money -= kabu*A[i-1]
            pos=0
            
    best = max(best,money+kabu*A[i])
            
print(best)

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

money=1000
pos = 1
kabu = 0

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

t = [-1] * (N + 1)
t[0] = 1000
for i in range(N):
    t[i + 1] = max(t[i + 1], t[i])
    k = t[i] // A[i]
    y = t[i] % A[i]
    for j in range(i + 1, N):
        t[j + 1] = max(t[j + 1], k * A[j] + y)
print((t[N]))


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

t = [-1] * (N + 1)
t[0] = 1000
for i in range(N):
    k = t[i] // A[i]
    y = t[i] % A[i]
    for j in range(i, N):
        t[j + 1] = max(t[j + 1], k * A[j] + y)
print((t[N]))
# Original solution
N = int(eval(input()))
A = list(map(int,input().split()))
money = 1000
kabu = 0
for i in range(N-1):
    if A[i+1] < A[i]:
        while kabu != 0:
            money += A[i]
            kabu -= 1
    else:
        while money >= A[i]:
            money -= A[i]
            kabu += 1
while kabu != 0:
    money += A[-1]
    kabu -= 1
print(money)


# 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+1] < A[i]:
        money += A[i] * kabu
        kabu = 0
    else:
        kabu += money//A[i]
        money -= A[i] * (money//A[i])
    #print(kabu,money)
money += A[-1] * kabu


print(money)
# Original solution
n = int(eval(input()))
a = list(map(int, input().split()))
# dp[buy][sell]
dp = [0 for j in range(n)]
dp[0] = 1000
for i in range(n):
    ai = a[i]
    m = dp[i]
    s = m // ai

    for j in range(i + 1, n):
        dp[j] = max(dp[j], m + s * (a[j] - ai))

    for j in range(n - 1):
        dp[j + 1] = max(dp[j + 1], dp[j])
print((dp[-1]))


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

m = 1000
s = 0

for i in range(1, n):
    a_next = a[i]
    if a_cur < a_next:
        # buy current and sell next
        s = m // a_cur
        m += s * (a_next - a_cur)
    a_cur = a_next
print(m)
# Original solution
n = int(eval(input()))
a = list(map(int,input().split()))

dp = [[-1]*100000 for i in range(n+1)]
dp[0][0] = 1000


for i in range(n):
    for j in range(99999):
        dp[i+1][j] = max(dp[i+1][j],dp[i][j])
        if dp[i+1][j] >= a[i]:
            dp[i+1][j+1] = max(dp[i+1][j+1],dp[i+1][j]-a[i])
        
    for j in range(99999,0,-1):
        if dp[i+1][j] >= 0:
             dp[i+1][j-1] = max(dp[i+1][j-1],dp[i+1][j]+a[i])
print((max(dp[-1])))


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

count = [1000,0]
x = a[0]
for i in range(1,n):
    if a[i] > x:
        d = count[0]//x
        count = [count[0]-d*x, d+count[1]]
    else:
        count = [count[0]+count[1]*x,0]
    x = a[i]
if count[1]:
    count[0] += count[1]*x
print((count[0]))
# Original solution
n, *a = list(map(int, open(0).read().split()))
m = 1000
for a, b in zip(a, a[1:]):
  if a < b:m = m // a * b + m % a
print(m)

# Optimized solution
n, *a = list(map(int, open(0).read().split()))
a += 1,
m = 1000

def groupby():
  c, res = [], []
  for i in range(n + 1):
    if a[i-1] <= a[i]:
      pass
    else:
      res += [c[0], c[-1]],
      c = []
    c += a[i],
  return res

for i, j in groupby():
  m = m // i * j + m % i
print(m)
# Original solution
N = int(eval(input()))
A = list(map(int, input().split()))

iStock = 0
iMoney = 1000

for i in range(N-1):
    if A[i] < A[i + 1]:
        # A[i]Day 株購入 & a[i+1]Day 株売却
        iStock = iMoney // A[i]
        iMoney %= A[i]
        iMoney += iStock * A[i+1]
print(iMoney)


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

iStock = 0
iMoney = 1000

for i in range(N-1):
    if A[i] < A[i + 1]:
        # A[i]Day 株購入 & A[i+1]Day 株売却
        iStock = iMoney // A[i]
        iMoney %= A[i]
        iMoney += iStock * A[i+1]
print(iMoney)
# Original solution
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(100000)
from functools import lru_cache
 
    
class Solution:
    def __init__(self,prices):
        self._max = 0
        self.prices = prices
        self.n = len(prices)
    
    @lru_cache(None)
    def transaction(self, money, stock, i, last_buy):
        if i == len(self.prices):
            self._max = max(self._max, money)
            return
        
        _stock,_money = stock,money

        ## buy
        if money >= self.prices[i]:
            stock, money = divmod(money, self.prices[i])
            self.transaction(money, stock, i + 1, self.prices[i])
        # backtracking
        money,stock = _money,_stock
 
        ## sell
        if stock > 0 and self.prices[i] > last_buy:
            stock, money = 0, stock * self.prices[i] + money
            if money > 1000:
                self.transaction(money, 0, i + 1,0)
        # backtracking
        money,stock = _money,_stock
 
        ## do nothing
        self.transaction(money, stock, i + 1,last_buy)
 
 
def main():
    n = int(input().strip())
    A = [int(i) for i in input().strip().split()]
    solver = Solution(A)
    solver.transaction(1000, 0, 0, 0)
    print((solver._max))
    

if __name__ == "__main__":
    main()

# Optimized solution
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(100000)
 

def maxProfit(prices) -> int:
    if len(prices) < 2:
        return 0
    ans = 1000
    for i in range(1,len(prices)):
        if prices[i] > prices[i - 1]:
            stock = ans // prices[i - 1]
            ans += stock * (prices[i] - prices[i - 1]) 
    return ans

def main():
    n = int(input().strip())
    A = [int(i) for i in input().strip().split()]

    ans = maxProfit(A)
    print(ans)


if __name__ == "__main__":
    main()
# Original solution
n = int(eval(input()))
a = list(map(int,input().split()))

k_y = [1000]

for i in range(n):
	genkin_list = [ hk * a[i] + hy for hk,hy in enumerate(k_y) ]  #所持株、金
	genkin_list_max = max(genkin_list)
	max_index = genkin_list.index(genkin_list_max)
	k_y = [ genkin_list_max - a[i] * j for j in range(genkin_list_max // a[i]+1 ) ]
	
print(( k_y[0] ))


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

k_y = [1000]
yen = 1000
resyen = 1000
kabu_max = 0
for i in range(n):
	#株を売り払うケース
	newyen = max( yen, kabu_max * a[i] + resyen)
	
	#株を最大買うケース
	kabu_max_new = max( kabu_max + resyen // a[i], yen // a[i] )
	if kabu_max_new == yen // a[i]:
		if kabu_max_new == kabu_max + resyen // a[i]:
			resyen = max( yen % a[i], resyen % a[i])
		else:
			resyen = yen % a[i]
	
	yen = newyen
	kabu_max = kabu_max_new
	#print(kabu_max,yen,resyen)
print( yen )
# Original solution
def INT():
    return int(eval(input()))

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

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

N = INT()
A = LI()
ans = 1000
purchase = 0

for i in range(1, N):
    tmp = ans
    
    if A[i] > A[i - 1]:
        while True:
            if tmp - A[i - 1] < 0:
                break
            tmp -= A[i - 1]
            purchase += 1
        ans = max(ans, tmp + A[i] * purchase)
        purchase = 0

print(ans)

# Optimized solution
def INT():
    return int(eval(input()))

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

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

N = INT()
A = LI()
ans = 1000

for i in range(1, N):
    tmp = ans
    if A[i] > A[i - 1]:
        purchase = tmp // A[i - 1]
        ans = max(ans, tmp + (A[i] - A[i - 1]) * purchase)
        
print(ans)
# Original solution
from collections import deque

n = int(eval(input()))
a = list(map(int,input().split()))
m = 1000
ans = 1000
ans_list=[]

q = deque([[1000, 0, n, 0]])

while len(q) != 0:
    tmp = q.popleft()
    m,k,d,i = tmp[0],tmp[1],tmp[2],tmp[3]
    if d == 0 and m > ans:
        ans = m
        ans_list.append(m)
    elif d > 1:
        x = m//a[i]
        q.append([m-(x*a[i]),x+k,d-1,i+1])
        q.append([m+(k*a[i]),0,d-1,i+1])
        q.append([m,k,d-1,i+1])
    elif d == 1:
        q.append([m+(k*a[i]),0,d-1,i+1])

print(ans)


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

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

print(ans)
# Original solution
import sys
from collections import deque,defaultdict

I=sys.stdin.readline

def ii():
	return int(I().strip())
def li():
	return list(map(int,I().strip().split()))

def mi():
	return list(map(int,I().strip().split()))


def main():
	n=ii()
	arr=li()
	p=1000
	for i in range(n-1):
		if arr[i]==arr[i+1]:
			pass
		elif arr[i]<arr[i+1]:
			buy=p//arr[i]
			p+=(arr[i+1]-arr[i])*buy

	
	print(p)








		


		










		






if __name__ == '__main__':
	main()

# Optimized solution
import sys
from collections import deque,defaultdict

I=sys.stdin.readline

def ii():
	return int(I().strip())
def li():
	return list(map(int,I().strip().split()))

def mi():
	return list(map(int,I().strip().split()))


def main():
	n=ii()
	arr=li()
	p=1000
	for i in range(n-1):
		if arr[i]<arr[i+1]:
			buy=p//arr[i]
			p+=(arr[i+1]-arr[i])*buy

	
	print(p)








		


		










		






if __name__ == '__main__':
	main()
# Original solution
import io
import os

from collections import Counter, defaultdict, deque


from functools import lru_cache
import sys

sys.setrecursionlimit(10 ** 5)


def solve(N, A):
    @lru_cache(maxsize=None)
    def maxProfitAtEnd(i, money, stocks):
        if i == N - 1:
            # Sell all remaining
            return money + stocks * A[i]

        # no op
        best = maxProfitAtEnd(i + 1, money, stocks)
        # sell
        best = max(best, maxProfitAtEnd(i + 1, money + stocks * A[i], 0))
        # buy
        numStock = money // A[i]
        best = max(
            best, maxProfitAtEnd(i + 1, money - numStock * A[i], stocks + numStock)
        )

        return best

    return maxProfitAtEnd(0, 1000, 0)


if __name__ == "__main__":
    input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline

    (N,) = [int(x) for x in input().split()]
    A = [int(x) for x in input().split()]
    ans = solve(N, A)
    print(ans)


# Optimized solution
import io
import os

from collections import Counter, defaultdict, deque


from functools import lru_cache
import sys

sys.setrecursionlimit(10 ** 5)


def solve(N, A):
    @lru_cache(maxsize=None)
    def maxProfitAtEnd(i, money, stocks):
        if i == N - 1:
            # Sell all remaining
            return money + stocks * A[i]

        # no op
        best = maxProfitAtEnd(i + 1, money, stocks)
        # sell
        best = max(best, maxProfitAtEnd(i + 1, money + stocks * A[i], 0))
        # buy
        numStock = money // A[i]
        best = max(
            best, maxProfitAtEnd(i + 1, money - numStock * A[i], stocks + numStock)
        )

        return best

    return maxProfitAtEnd(0, 1000, 0)


def solve(N, A):
    money = 1000
    stock = 0
    for i in range(N - 1):
        if A[i] < A[i + 1]:
            # Buy on i
            numStock = money // A[i]
            money -= numStock * A[i]
            stock += numStock
            # Sell on i + 1
            money += stock * A[i + 1]
            stock = 0
    assert stock == 0
    return money


if __name__ == "__main__":
    input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline

    (N,) = [int(x) for x in input().split()]
    A = [int(x) for x in input().split()]
    ans = solve(N, A)
    print(ans)
# Original solution
import sys
N = int(eval(input()))
A = list(map(int, input().split()))

kai = [False] * N
uri = [False] * N
# 買いポイント探す
i = 0


# すべて同じ株価or単調減少
tmp = A[0]
flag = True
for i in range(1, N):
    if A[i-1] < A[i]:
        flag = False

if flag:
    print((1000))
    sys.exit(0)

start = 10000
stop = 10000

for i in range(1, N):
    if A[i-1] < A[i] and stop != i-1:
        start = i-1
        stop = i
    elif A[i-1] < A[i] and stop == i-1:
        stop = i
    elif A[i-1] >= A[i] and start != 10000 and stop != 10000:
        kai[start] = True
        uri[stop] = True
        start = 10000
        stop = 10000
    if i == N-1 and start != 10000 and stop != 10000:
        kai[start] = True
        uri[stop] = True
cnt = 0
kingaku = 1000
for i in range(N):
    if kai[i]:
        cnt = kingaku // A[i]
        kingaku -= A[i] * cnt
    if uri[i]:
        kingaku += A[i] * cnt
        cnt = 0
    if i == N-1:
        kingaku += A[i] * cnt
print(kingaku)






# 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])
ans = 0
for i in range(N):
    ans = max(ans, dp[i])
print(ans)
# Original solution
n = int(eval(input()))
A = [*list(map(int, input().split()))] + [0]
yen = 1000
kabu_yen = kabu_n = 0
for i in range(1,n+1):
    if A[i-1] < A[i]: # buy
        m = yen // A[i-1]
        cost = m * A[i-1]
        yen -= cost
        kabu_yen += cost
        kabu_n += m
    elif A[i-1] > A[i]: # sell
        yen += kabu_n * A[i-1]
        kabu_yen = kabu_n = 0
print(yen)


# Optimized solution
n = int(eval(input()))
A = [*list(map(int, input().split()))] + [0]
yen = 1000
kabu_yen = kabu_n = 0
for i in range(n):
    if A[i] < A[i+1]: # buy
        m = yen // A[i]
        cost = m * A[i]
        yen -= cost
        kabu_yen += cost
        kabu_n += m
    elif A[i] > A[i+1]: # sell
        yen += kabu_n * A[i]
        kabu_yen = kabu_n = 0
print(yen)
# Original solution
n = int(eval(input()))
A = [*list(map(int, input().split()))] + [0]
yen = 1000
kabu_yen = kabu_n = 0
for i in range(n):
    if A[i] < A[i+1]: # buy
        m = yen // A[i]
        cost = m * A[i]
        yen -= cost
        kabu_yen += cost
        kabu_n += m
    elif A[i] > A[i+1]: # sell
        yen += kabu_n * A[i]
        kabu_yen = kabu_n = 0
print(yen)


# Optimized solution
n = int(eval(input()))
A = [*list(map(int, input().split()))] + [0]
yen, stock = 1000, 0
nxt = A[0]
for now in A[1:]:
    now, nxt = nxt, now
    if now < nxt:
        stock += yen // now
        yen -= yen // now * now
    else:
        yen += stock * now
        stock = 0
print((yen + stock * nxt))
# Original solution
n = int(eval(input()))
A = [0] + [*list(map(int, input().split()))]
dp_stock = [0]*(n+1)
dp_yen = [0]*(n+1)
dp_yen[0] = 1000
for day in range(1, n+1):
    dp_stock[day] = max(dp_stock[day-1], dp_yen[day-1] // A[day])
    remain = dp_yen[day-1] - dp_stock[day-1]*A[day-1]
    dp_yen[day] = max(dp_yen[day-1], remain + dp_stock[day-1] * A[day])
print((dp_yen[n]))


# Optimized solution
n = int(eval(input()))
A = [0] + [*list(map(int, input().split()))] + [0]
dp_yen = [0]*(n+1)
dp_yen[1] = 1000
for day in range(1, n):
    stock = 0
    if A[day] > 0: stock = dp_yen[day] // A[day]
    remain = dp_yen[day] - stock*A[day]
    dp_yen[day+1] = max(dp_yen[day], remain + stock * A[day+1])
print((dp_yen[n]))
# Original solution
n = int(eval(input()))
A = [*list(map(int, input().split()))] + [0]
dp_yen = [0]*(n+1)
dp_yen[0] = 1000
for day in range(n):
    dp_yen[day+1] = max(dp_yen[day], dp_yen[day] + (A[day+1] - A[day]) * (dp_yen[day] // A[day]))
print((dp_yen[n]))


# Optimized solution
n = int(eval(input()))
A = [*list(map(int, input().split()))] + [0]
dp_yen = [1000]*(n+1)
for day in range(n):
    dp_yen[day+1] = max(dp_yen[day], dp_yen[day] + dp_yen[day]//A[day] * (A[day+1] - A[day]))
print((dp_yen[n]))
# Original solution
from collections import deque
n = int(eval(input()))
a = list(map(int,input().split()))
stack = deque()
stack.append([1000,0,0,200])
ans = []
while stack:
  money,kabu,i,temp = stack.pop()
  ans.append(money)
  if i<n:
    stack.append([money,kabu,i+1,temp])
    if a[i]<temp and a[i]<=money:
      kabu += money//a[i]
      money %= a[i]
      stack.append([money,kabu,i+1,a[i]])
    elif a[i]>temp and kabu>=1:
      money += a[i]*kabu
      kabu = 0
      stack.append([money,kabu,i+1,a[i]])
    ans.append(money)
print((max(ans)))

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

# dp[i] = (i+1)日目終了時点での金額の最大値
# dp[i] = max(dp[i-1], {dp[j-1] % a[j] + (dp[j-1] // a[j]) * a[i] | j<i})
dp = [0] * (n + 1)
dp[0] = dp[1] = 1000
dp[2] = max(dp[0] % a[1] + (dp[0] // a[1]) * a[2], dp[1])

for i in range(1, n + 1):
    cand = dp[i - 1]
    for j in range(1, i):
        cand = max(cand, dp[j - 1] % a[j] + (dp[j - 1] // a[j]) * a[i])
    dp[i] = cand

print((dp[n]))


# 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] + (ans // a[i]) * a[i + 1]

print(ans)