CodeEff/ECCO huggingface dataset:
# Original solution
def main():
    N = int(eval(input()))
    *A, = list(map(int, input().split()))

    money = 1000

    low = A[0]
    high = -1
    for x in A:
        if high < x:
            high = x
            continue

        if high > x:
            money += (high - low) * (money // low)
            low = high = x

    money += max(0, high - low) * (money // low)

    print(money)


if __name__ == '__main__':
    main()


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

    money = 1000

    low = A[0]
    p = A[0]
    for x in A:
        if p > x:
            money += (p - low) * (money // low)
            low = x
        p = x

    money += max(0, p - low) * (money // low)

    print(money)


if __name__ == '__main__':
    main()
# Original solution
def main():
    N = int(eval(input()))
    *A, = list(map(int, input().split()))

    money = 1000

    low = A[0]
    p = A[0]
    for x in A:
        if p > x:
            money += (p - low) * (money // low)
            low = x
        p = x

    money += (p - low) * (money // low)

    print(money)


if __name__ == '__main__':
    main()


# Optimized solution
def main():
    _ = int(eval(input()))
    *A, = list(map(int, input().split()))
    A += [0]

    money = 1000
    stock = 0
    for a, b in zip(A, A[1:]):
        money += stock * a
        stock = 0
        if a < b:
            buy, rest = divmod(money, a)
            stock = buy
            money = rest
    print(money)


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

ans = 1000
buy = -1
for bit in range(2 ** n):
    money = 1000
    stock = 0
    for i in range(n):
        if (bit >> i) & 1:
            buy = i
            stock += money // A[i]
            money -= A[i] * (money // A[i])
        else:
            if buy == -1:
                continue
            elif A[buy] < A[i]:
                money += stock * A[i]
                stock = 0
    money += stock * A[-1]
    if money > ans:
        ans = money

print(ans)


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

money = 1000
stock = 0

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

money=1000
stocks=0

for i in range(N): 
    if i==N-1:
        #売る
        while stocks>0:
            money += A[i]
            stocks-=1    
    elif A[i+1]>A[i]:
        #買う
        while money>=A[i]:
            money -= A[i]
            stocks+=1
    elif A[i+1]<A[i]:
        #売る
        while stocks>0:
            money += A[i]
            stocks-=1
print(money)

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

money=1000
stocks=0

for i in range(N): 
    if i==N-1:
        #売る
        money+=(A[i]*stocks)
        stocks=0
    elif A[i+1]>A[i]:
        #買う
        plus_stock,money=divmod(money,A[i])
        stocks+=plus_stock
    elif A[i+1]<A[i]:
        #売る
        money+=(A[i]*stocks)
        stocks=0
print(money)
# Original solution
N = int(eval(input()))
A = list(map(int, input().split()))

money = 1000
stock = 0
for i in range(N - 1):
    if A[i] == A[i + 1]:
        continue
    elif A[i] > A[i + 1]:
        while stock > 0:
            money += A[i]
            stock -= 1
    elif A[i] < A[i + 1]:
        while money >= A[i]:
            money -= A[i]
            stock += 1
while stock > 0:
    money += A[N - 1]
    stock -= 1

print(money)

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

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

print(money)
# Original solution
N = int(eval(input()))
prices = [int(n) for n in input().split()]
money = 1000
stock = 0
p_today = prices[0]
for n in range(N-1):
    p_tomm = prices[n+1]
    if p_tomm >= p_today:
        while money >= p_today:
            stock += 1
            money -= p_today
    else:
        money += p_today * stock
        stock = 0
    p_today = p_tomm

if stock > 0:
    money += prices[-1] * stock

print(money)

# Optimized solution
N = int(eval(input()))
prices = [int(n) for n in input().split()]
money = 1000
stock = 0
p_today = prices[0]
for n in range(N-1):
    p_tomm = prices[n+1]
    if p_tomm >= p_today:
        n_stock = money // p_today
        stock += n_stock
        money = money - p_today * n_stock
        # while money >= p_today:
        #     stock += 1
        #     money -= p_today
    else:
        money += p_today * stock
        stock = 0
    p_today = p_tomm

if stock > 0:
    money += prices[-1] * stock

print(money)
# Original solution
import sys,bisect,string,math,time,functools,random,fractions
from heapq import heappush,heappop,heapify
from collections import deque,defaultdict,Counter
from itertools import permutations,combinations,groupby
rep=range;R=range
def Golf():n,*t=map(int,open(0).read().split())
def I():return int(input())
def S_():return input()
def IS():return input().split()
def LS():return [i for i in input().split()]
def MI():return map(int,input().split())
def LI():return [int(i) for i in input().split()]
def LI_():return [int(i)-1 for i in input().split()]
def NI(n):return [int(input()) for i in range(n)]
def NI_(n):return [int(input())-1 for i in range(n)]
def StoLI():return [ord(i)-97 for i in input()]
def ItoS(n):return chr(n+97)
def LtoS(ls):return ''.join([chr(i+97) for i in ls])
def RA():return map(int,open(0).read().split())
def GI(V,E,ls=None,Directed=False,index=1):
    org_inp=[];g=[[] for i in range(V)]
    FromStdin=True if ls==None else False
    for i in range(E):
        if FromStdin:
            inp=LI()
            org_inp.append(inp)
        else:
            inp=ls[i]
        if len(inp)==2:
            a,b=inp;c=1
        else:
            a,b,c=inp
        if index==1:a-=1;b-=1
        aa=(a,c);bb=(b,c);g[a].append(bb)
        if not Directed:g[b].append(aa)
    return g,org_inp
def GGI(h,w,search=None,replacement_of_found='.',mp_def={'#':1,'.':0},boundary=1):
    #h,w,g,sg=GGI(h,w,search=['S','G'],replacement_of_found='.',mp_def={'#':1,'.':0},boundary=1) # sample usage
    mp=[boundary]*(w+2);found={}
    for i in R(h):
        s=input()
        for char in search:
            if char in s:
                found[char]=((i+1)*(w+2)+s.index(char)+1)
                mp_def[char]=mp_def[replacement_of_found]
        mp+=[boundary]+[mp_def[j] for j in s]+[boundary]
    mp+=[boundary]*(w+2)
    return h+2,w+2,mp,found
def TI(n):return GI(n,n-1)
def accum(ls):
    rt=[0]
    for i in ls:rt+=[rt[-1]+i]
    return rt
def bit_combination(n,base=2):
    rt=[]
    for tb in R(base**n):s=[tb//(base**bt)%base for bt in R(n)];rt+=[s]
    return rt
def gcd(x,y):
    if y==0:return x
    if x%y==0:return y
    while x%y!=0:x,y=y,x%y
    return y
def YN(x):print(['NO','YES'][x])
def Yn(x):print(['No','Yes'][x])
def show(*inp,end='\n'):
    if show_flg:print(*inp,end=end)

mo=10**9+7
inf=float('inf')
FourNb=[(-1,0),(1,0),(0,1),(0,-1)];EightNb=[(-1,0),(1,0),(0,1),(0,-1),(1,1),(-1,-1),(1,-1),(-1,1)];compas=dict(zip('WENS',FourNb));cursol=dict(zip('LRUD',FourNb))
l_alp=string.ascii_lowercase
#sys.setrecursionlimit(10**7)
read=sys.stdin.buffer.read;readline=sys.stdin.buffer.readline;input=lambda:sys.stdin.readline().rstrip()

########################################################################################################################################################################

show_flg=False
show_flg=True

ans=0


n=I()
a=LI()
p=a[0]

x=1000
t=0
s=0
for i in range(n):
    if p<a[i]:
        s=x//p
        #t+=s
        x+=s*(a[i]-p)
    #show(x,s,a[i],p)
    p=a[i]
    
print(x)


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

fp = A[0]
tmp = 0
c = 1000
stock = 0
IsSearchTop = False
first = True
for i in range(1,N):
    if first:
        if fp > A[i]:
            fp = A[i]
        elif fp < A[i]:
            stock += c // fp
            c -= stock * fp
            IsSearchTop = True
            first = False
            fp = A[i]
            if i == N - 1:
                c += stock * fp
    else:
        if IsSearchTop:
            if fp <= A[i]:
                fp = A[i]
                if i == N-1:
                    c += stock * fp
            elif fp > A[i]:
                c += stock * fp
                stock = 0
                fp = A[i]
                IsSearchTop = False
        else:
            if fp >= A[i]:
                fp = A[i]
            elif fp < A[i]:
                stock += c // fp
                c -= stock * fp
                IsSearchTop = True
                fp = A[i]
                if i == N - 1:
                    c += stock * fp
print(c)














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

fp = A[0]
tmp = 0
c = 1000
stock = 0
IsSearchTop = False
first = True
for i in range(1,N):
#
        if IsSearchTop:
            if fp <= A[i]:
                fp = A[i]
                if i == N-1:
                    c += stock * fp
            elif fp > A[i]:
                c += stock * fp
                stock = 0
                fp = A[i]
                IsSearchTop = False
        else:
            if fp >= A[i]:
                fp = A[i]
            elif fp < A[i]:
                stock += c // fp
                c -= stock * fp
                IsSearchTop = True
                fp = A[i]
                if i == N - 1:
                    c += stock * fp
print(c)
# Original solution
N = int(eval(input()))
A = list(map(int, input().split()))

A.append(0)

B = []
f = True
for i in range(N):
    if f:
        if A[i] < A[i+1]:
            B.append(A[i])
            f = False
    else:
        if A[i] > A[i+1]:
            B.append(A[i])
            f = True


if len(B) == 0:
    print((1000))
else:
    res = 1000
    xx = len(B)//2+1
    B = [0]+B+[10**10]
    for i in range(2**xx):
        en = 1000
        ka = 0
        for j in range(xx):
            if (i>>j)&1:
                en += ka*B[j*2]
                ka = 0
                ka = en//B[j*2+1]
                en = en%B[j*2+1]
        else:
            res = max(en, res)

    print(res)

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

kabu = 0
en = 1000

for i in range(N):
    a, b = divmod(en, A[i])
    kabu += a
    en = b
    if A[i+1] < A[i]:
        en += kabu*A[i]
        kabu = 0

print(en)
# Original solution
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8') 
inf = float('inf') ;mod = 10**9+7 
mans = inf ;ans = 0 ;cnt = 0 ;pro = 1

n = int(eval(input()))
A = list(map(int, input().split()))
now = 1000
for i in range(n-1):
    if A[i] < A[i+1]:
        stocks = now//A[i]
        now += (A[i+1] - A[i])*stocks
print(now)

# Optimized solution
n = int(eval(input()))
A = list(map(int, input().split()))
now = 1000
for i in range(n-1):
    if A[i] < A[i+1]:
        stocks = now // A[i]
        now += (A[i+1] - A[i])*stocks
print(now)
# Original solution
def solve():
  ans = 0
  N = int(eval(input()))
  A = [float('inf')]+list(map(int, input().split()))+[-float('inf')]
  UD = [0]*(N+1)
  for i in range(N+1):
    if A[i]>A[i+1]:
      UD[i] = -1
    elif A[i]<A[i+1]:
      UD[i] = 1
    else:
      UD[i] = UD[i-1]
  UD2 = [0]*N
  for i in range(N):
    if UD[i]>UD[i+1]:
      UD2[i] = -1
    elif UD[i]<UD[i+1]:
      UD2[i] = 1
  stock = 0
  money = 1000
  if -1 not in UD2:
    ind = -1
  else:
    ind = (N-1)-UD2[::-1].index(-1)
  for i in range(N):
    if UD2[i]==-1:
      money += A[i+1]*stock
      stock = 0
      if i==ind:
        break
    elif UD2[i]==1:
      stock,money = divmod(money,A[i+1])
  return money
print((solve()))

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

def sell(money,stock,price):
  money += price*stock
  stock = 0
  return money, stock

def buy(money,price):
  stock,money = divmod(money,price)
  return money,stock

money = 1000
stock = 0
for i in range(N):
  money, stock = sell(money,stock,A[i])
  if i<N-1 and A[i]<A[i+1]:
    money, stock = buy(money,A[i])
print(money)
# Original solution
n = int(eval(input()))
a = list(map(int, input().split()))

stock_dp = [[0, 0] for _ in range(n+1)]
value_dp = [0] * (n + 1)

value_dp[0] = 1000
for i in range(1, n + 1):
    x = value_dp[i - 1]
    y = stock_dp[i - 1][0] + stock_dp[i - 1][1] * a[i - 1]
    if x > y:
        value_dp[i] = x
    else:
        value_dp[i] = y
    x = value_dp[i - 1] // a[i - 1] 
    y = stock_dp[i - 1][0] // a[i - 1] + stock_dp[i - 1][1]
    rx = value_dp[i - 1] % a[i - 1]
    ry = stock_dp[i - 1][0] % a[i - 1]
    if x > y:
        stock_dp[i][0] = rx
        stock_dp[i][1] = x
    elif x < y:
        stock_dp[i][0] = ry
        stock_dp[i][1] = y
    else:
        stock_dp[i][0] = max(rx, ry)
        stock_dp[i][1] = x
print((value_dp[n]))

    

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

stock = 0
rest  = 0
value = 1000

for i in range(1, n + 1):
    value = max(value, stock * a[i - 1] + rest)
    stock = value // a[i - 1]
    rest = value % a[i - 1]
print(value)
# Original solution
n = int(eval(input()))
a = list(map(int, input().split()))

state_of_up_or_down = False
money = 1000
min_price = a[0]
max_price = a[0]
for i in range(1, n):
    if a[i] > a[i - 1]:
        # min_price = min(a[i - 1], min_price)
        max_price = a[i]
        state_of_up_or_down = True
        if i == n - 1:
            money = (money // min_price) * max_price + money % min_price
    elif a[i] == a[i - 1]:
        if i == n - 1:
            money = (money // min_price) * max_price + money % min_price        
        pass
    else:
        if state_of_up_or_down:
            money = (money // min_price) * max_price + money % min_price
            state_of_up_or_down = False
        # max_price = a[i]
        min_price = a[i]
    # print(money, min_price, state_of_up_or_down)
print(money)

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

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

# state_of_up_or_down = False
money = 1000
# min_price = a[0]
# max_price = a[0]
for i in range(1, n):
    if a[i] > a[i - 1]:
        # max_price = a[i]
        # state_of_up_or_down = True
        money = (money // a[i-1]) * a[i] + money % a[i-1]
    # elif a[i] == a[i - 1]:
    #     if i == n - 1:
    #         money = (money // min_price) * max_price + money % min_price        
    #     pass
    else:
        pass
    #     if state_of_up_or_down:
    #         money = (money // min_price) * max_price + money % min_price
    #         state_of_up_or_down = False
    #     min_price = a[i]
    # print(money, min_price, state_of_up_or_down)
print(money)

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

money = 1000

for i in range(1, n):
    if a[i] > a[i - 1]:
        money = (money // a[i-1]) * a[i] + money % a[i-1]
    else:
        pass

print(money)
# Original solution
from bisect import bisect_right

def main():
    N = int(eval(input()))
    A = list(map(int, input().split()))
    INF = 10 ** 18
    last_max = A[0]
    last_min = A[0]

    money = 1000
    stock = 0
    old_trend = 0
    trend = A[1] - A[0]
    buy_point = []
    bought_point = []

    for i in range(N-1):
        trend = A[i+1] - A[i]
        if trend * old_trend > 0 or trend == 0:
            continue
        else:
            if trend > 0:
                buy_point.append(i)
            if trend < 0:
                bought_point.append(i)
        old_trend = trend

    if len(buy_point) > len(bought_point):
        bought_point.append(N-1)

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

            nx_bought_idx = bisect_right(bought_point,i)
            bought_value = A[nx_bought_idx]
            j = i - 1
            while j >= 0 and money >= 100:
                if A[j] < bought_value and money >= A[i]:
                    money -= A[j]
                    stock += 1
                    break
                j -= 1
        
        if i in bought_point:
            bought = stock
            stock = 0
            money += bought * A[i]
    print(money)
    


if __name__ == "__main__":
    main()

# Optimized solution
from bisect import bisect_right

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

    money = 1000
    stock = 0
    old_trend = 0
    trend = A[1] - A[0]
    buy_point = []
    bought_point = []

    for i in range(N-1):
        trend = A[i+1] - A[i]
        if trend * old_trend > 0 or trend == 0:
            continue
        else:
            if trend > 0:
                buy_point.append(i)
            if trend < 0:
                bought_point.append(i)
        old_trend = trend

    if len(buy_point) > len(bought_point):
        bought_point.append(N-1)

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

        
        if i in bought_point:
            bought = stock
            stock = 0
            money += bought * A[i]
    print(money)
    


if __name__ == "__main__":
    main()
# Original solution
import sys
import heapq, math
from bisect import bisect_right
from itertools import zip_longest, permutations, combinations, combinations_with_replacement
from itertools import accumulate, dropwhile, takewhile, groupby
from functools import lru_cache
from copy import deepcopy

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

B = [A[0]]

for i in range(1, N):
    if A[i - 1] != A[i]:
        B.append(A[i])

N = len(B)


def solve():
    ret = 1000
    l = 0
    while l < N:
        while l < N - 1 and B[l] > B[l + 1]:
            l += 1

        if l == N - 1:
            return ret

        C = [B[l]]
        while l < N - 1 and B[l] < B[l + 1]:
            C.append(B[l + 1])
            l += 1

        cnt = ret // C[0]
        ret -= cnt * C[0]
        ret += cnt * C[-1]

        l += 1
    return ret


print((solve()))

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

i = 0

yen = 1000
while i < N:
    while i < N - 1 and A[i] >= A[i + 1]:
        i += 1

    if i == N - 1:
        break

    x = i
    while i < N - 1 and A[i] <= A[i + 1]:
        i += 1

    y = i

    cnt = yen // A[x]
    yen = yen - A[x] * cnt + A[y] * cnt

print(yen)
# Original solution
n = int(eval(input()))
alst = list(map(int, input().split()))
lst = [[0, [0, 0]] for _ in range(n)]

lst[0][0] = 1000
lst[0][1][0] = 1000 // alst[0]
lst[0][1][1] = 1000 % alst[0]
for i, num in enumerate(alst[1:], start = 1):
    m1 = lst[i - 1][1][1] + lst[i - 1][1][0] * num
    lst[i][0] = max(lst[i - 1][0], m1)
    lst[i][1][0] = lst[i][0] // num
    lst[i][1][1] = lst[i][0] % num
    
print((lst[-1][0]))

# Optimized solution
n = int(eval(input()))
alst = list(map(int, input().split()))
dp = [[1000, [0, 0]]]

for a in alst:
    tmp1 = max(dp[-1][0], dp[-1][1][0] * a + dp[-1][1][1])
    tmp2 = tmp1 // a
    tmp3 = tmp1 % a
    dp.append([tmp1, [tmp2, tmp3]])
print((dp[-1][0]))
# Original solution
N=int(eval(input()))
A=list(map(int, input().split()))
A.append(0)
L=[0]*N
L[0]=1000

# dpしろ

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

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

d = [0]*N
d[0] = 1000
for i in range(1, N):
    if A[i-1] < A[i]:
        d[i] = d[i-1]+(d[i-1]//A[i-1])*(A[i]-A[i-1])
    else:
        d[i] = d[i-1]
print((d[-1]))
# Original solution
n = int(eval(input()))
A = list(map(int, input().split()))
M = 1000
for i in range(n-1):
    dp = list(range(M+1))
    a, b = A[i], A[i+1]
    for j in range(M+1):
        if j >= a:
            dp[j] = max(dp[j-a]+b, dp[j])
    M = dp[M]
ans = M
print(ans)

# Optimized solution
n = int(eval(input()))
A = list(map(int, input().split()))
x, y, z = 1000, 0, 1000
for a in A:
  s1, t1 = divmod(x, a)
  s2, t2 = divmod(z, a)
  s2 += y
  if s1 > s2:
    y, z = s1, t1
  elif s2 > s1:
    y, z = s2, t2
  else:
    y, z = s1, max(t1, t2)
  x = max(x, y*a+z)
ans = x
print(ans)
# 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):
        kabu = dp[j] // A[j]
        money = dp[j] + (A[i] - A[j]) * kabu
        dp[i] = max(dp[i], money)

print((dp[-1]))

# Optimized solution
N = int(eval(input()))

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

money = 1000

for i in range(N-1):
    t = money + (A[i + 1] - A[i]) * (money // A[i])
    money = max(money, t)

print(money)
# Original solution
def solve():
    N = int(eval(input()))
    A = list(map(int, input().split()))
    dp = [0 for j in range(N+1)]
    dp[0] = 1000
    for i in range(1, N+1):
        for j in range(i):
            dp[i] = max(dp[i], dp[j])
        for j in range(1, i):
            dp[i] = max(dp[i], dp[j] % A[j-1]+A[i-1]*(dp[j]//A[j-1]))
    ans = dp[N]
    print(ans)


if __name__ == "__main__":
    solve()

# Optimized solution
def solve():
    N = int(eval(input()))
    A = list(map(int, input().split()))
    ans = 1000
    for i in range(1, N):
        x, y = A[i-1], A[i]
        if (x < y):
            ans = y*(ans//x) + ans % x
    print(ans)


if __name__ == "__main__":
    solve()
# Original solution
N = int(eval(input()))
A = list(map(int, input().split()))

ans = 0
def dfs(i, stock, money):
    global N
    global A
    global ans

    # print(i, stock, money)
    if i == N:
        ans = max(ans, money)
        return

    nextStock = int(stock)
    nextMoney = int(money)
    dfs(i+1, nextStock, nextMoney)
    
    buyStock = money//A[i]
    nextStock = stock + buyStock
    nextMoney = money - buyStock*A[i]
    dfs(i+1, nextStock, nextMoney)

    nextStock = 0
    nextMoney = money + stock * A[i]
    dfs(i+1, nextStock, nextMoney)

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


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

money = 1000
stack = 0

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