from collections import defaultdict
import itertools

N = int(input())
AA = list(map(int, input().split()))
GA = itertools.groupby(AA)
A = []
for key, group in GA:
    A.append(key)

d = defaultdict(lambda: 0)
d[0] = 1000

for i in range(len(A)):
    dd = d.copy()
    for s,m in dd.items():
        if m%A[i] != 0:
            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]
        else:
            d[s+m//A[i]]=0
        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])


