from collections import defaultdict

N = int(input())
A = list(map(int, input().split()))
d = defaultdict(lambda: 0)
d[0] = 1000

for i in range(N):
    dd = d.copy()
    for s,m in dd.items():
        temp = m//A[i]
        for j in range(1,temp+1):
            if(d[s+j]<m-j*A[i]):
                d[s+j]=m-j*A[i]
        for j in range(1,s+1):
            if(d[s-j]<m+j*A[i]):
                d[s-j]=m+j*A[i]

print(d[0])



