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)

N = int(eval(input()))

A = [0] + list(map(int, input().split()))



dp = [0] * (N+1)

dp[1] = 1000

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

    dp[i] = dp[i-1]

    for j in range(1, i):

        stock = dp[j] // A[j]

        momey = dp[j] + (A[i] - A[j]) * stock

        dp[i] = max(dp[i], momey)

print((dp[N]))
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)

N = int(eval(input()))
A = [0] + list(map(int, input().split()))
dp = [0] * (N + 1)
dp[1] = 1000
for i in range(2, N + 1):
    dp[i] = dp[i - 1]
    for j in range(1, i):
        stock = dp[j] // A[j]
        momey = dp[j] + (A[i] - A[j]) * stock
        dp[i] = max(dp[i], momey)
print((dp[N]))

-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) +A = [0] + list(map(int, input().split())) +dp = [0] * (N + 1) +dp[1] = 1000 +for i in range(2, N + 1): +    dp[i] = dp[i - 1] +    for j in range(1, i): +        stock = dp[j] // A[j] +        momey = dp[j] + (A[i] - A[j]) * stock +        dp[i] = max(dp[i], momey) +print((dp[N]))