import sys
sys.setrecursionlimit(4100000)

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

dp = [[-1] * (1000000) for i in range(N + 1)]

def dfs(i, money, kabu_num):
    if dp[i][money] >= 0:
        return dp[i][money]

    if i == N:
        return money

    # 買う
    a = dfs(i + 1, money % A[i], money // A[i] + kabu_num)
    # 売る
    b = dfs(i + 1, money + A[i] * kabu_num, 0)
    # 何もしない
    c = dfs(i + 1, money, kabu_num)

    dp[i][money] = max([a, b, c])

    return dp[i][money]

print(dfs(0, 1000, 0))
