n, *a = list(map(int, open(0).read().split()))

m = 1000

for a, b in zip(a, a[1:]):

  if a < b:m = m // a * b + m % a

print(m)
n, *a = list(map(int, open(0).read().split()))

a += 1,

m = 1000



def groupby():

  c, res = [], []

  for i in range(n + 1):

    if a[i-1] <= a[i]:

      pass

    else:

      res += [c[0], c[-1]],

      c = []

    c += a[i],

  return res



for i, j in groupby():

  m = m // i * j + m % i

print(m)
n, *a = list(map(int, open(0).read().split()))
m = 1000
for a, b in zip(a, a[1:]):
    if a < b:
        m = m // a * b + m % a
print(m)

n, *a = list(map(int, open(0).read().split()))
a += (1,)
m = 1000


def groupby():
    c, res = [], []
    for i in range(n + 1):
        if a[i - 1] <= a[i]:
            pass
        else:
            res += ([c[0], c[-1]],)
            c = []
        c += (a[i],)
    return res


for i, j in groupby():
    m = m // i * j + m % i
print(m)

+a += (1,) -for a, b in zip(a, a[1:]): -    if a < b: -        m = m // a * b + m % a + + +def groupby(): +    c, res = [], [] +    for i in range(n + 1): +        if a[i - 1] <= a[i]: +            pass +        else: +            res += ([c[0], c[-1]],) +            c = [] +        c += (a[i],) +    return res + + +for i, j in groupby(): +    m = m // i * j + m % i