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

memo = {}


def solve(i, j, k):
    if i == N - 1:
        return j + A[i] * k
    if (i, j, k) in memo:
        return memo[(i, j, k)]
    res = max(solve(i + 1, j, k),
              solve(i + 1, j % A[i], k + j // A[i]),
              solve(i + 1, j + A[i] * k, 0))
    memo[(i, j, k)] = res
    return res


print(solve(0, 1000, 0))