import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N = int(input())
As = list(mapint())

dp = [[0]*1000 for _ in range(N+1)]
s = set([(1000, 0)])

money = 1000
for i in range(N):
    s = list(s)
    a = As[i]
    nx = set()
    for m, num in s:
        m2 = m
        cnt = 0
        while m2>=0:
            nx.add((m2, num+cnt))
            m2 -= a
            cnt += 1
        for n in range(1, num+1):
            nx.add((m+a*n, num-n))
    s = nx

lis = list(nx)
lis.sort()
print(lis[-1][0])