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

        s += m // a_cur

        m -= m // a_cur * a_cur

    else:

        # sell

        m += s * a_cur

        s = 0

    a_cur = a_next

m += s * a_cur

print(m)
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)

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
        s += m // a_cur
        m -= m // a_cur * a_cur
    else:
        # sell
        m += s * a_cur
        s = 0
    a_cur = a_next
m += s * a_cur
print(m)

-        # buy current and sell next -        s = m // a_cur -        m += s * (a_next - a_cur) +        # buy +        s += m // a_cur +        m -= m // a_cur * a_cur +    else: +        # sell +        m += s * a_cur +        s = 0 +m += s * a_cur