#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)
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]))
# 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)

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]))

-# bottomかtopか -an = [] +dp = [0] * n +dp[0] = 1000 -    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) +    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]))