N = int(eval(input()))

money = 1000

M = N//2

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

prices.append(0)

dp = [[0 for j in range(M+1)]for i in range(N+1)]

dp[0][0] = money

max_p = money



for i in range(1, N+1):

    for j in range(M+1):

        dp[i][j] = dp[i-1][j]

        if j > 0:

            for l in range(i):

                x = dp[l][j-1] % prices[l] + dp[l][j-1]//prices[l]*prices[i]

                if dp[i][j] < x:

                    dp[i][j] = x

            if max_p < dp[i][j]:

                max_p = dp[i][j]

print(max_p)

N = int(eval(input()))

money = 1000

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

A.append(0)

kabu = 0

for i in range(N):

    if A[i] <= A[i+1]:

        buy = money//A[i]

        money -= buy*A[i]

        kabu += buy

    if A[i] >= A[i+1]:

        money += kabu*A[i]

        kabu = 0

print(money)
N = int(eval(input()))
money = 1000
M = N // 2
prices = list(map(int, input().split()))
prices.append(0)
dp = [[0 for j in range(M + 1)] for i in range(N + 1)]
dp[0][0] = money
max_p = money
for i in range(1, N + 1):
    for j in range(M + 1):
        dp[i][j] = dp[i - 1][j]
        if j > 0:
            for l in range(i):
                x = dp[l][j - 1] % prices[l] + dp[l][j - 1] // prices[l] * prices[i]
                if dp[i][j] < x:
                    dp[i][j] = x
            if max_p < dp[i][j]:
                max_p = dp[i][j]
print(max_p)

N = int(eval(input()))
money = 1000
A = list(map(int, input().split()))
A.append(0)
kabu = 0
for i in range(N):
    if A[i] <= A[i + 1]:
        buy = money // A[i]
        money -= buy * A[i]
        kabu += buy
    if A[i] >= A[i + 1]:
        money += kabu * A[i]
        kabu = 0
print(money)

-M = N // 2 -prices = list(map(int, input().split())) -prices.append(0) -dp = [[0 for j in range(M + 1)] for i in range(N + 1)] -dp[0][0] = money -max_p = money -for i in range(1, N + 1): -    for j in range(M + 1): -        dp[i][j] = dp[i - 1][j] -        if j > 0: -            for l in range(i): -                x = dp[l][j - 1] % prices[l] + dp[l][j - 1] // prices[l] * prices[i] -                if dp[i][j] < x: -                    dp[i][j] = x -            if max_p < dp[i][j]: -                max_p = dp[i][j] -print(max_p) +A = list(map(int, input().split())) +A.append(0) +kabu = 0 +for i in range(N): +    if A[i] <= A[i + 1]: +        buy = money // A[i] +        money -= buy * A[i] +        kabu += buy +    if A[i] >= A[i + 1]: +        money += kabu * A[i] +        kabu = 0 +print(money)