INF=10**30
N=int(input())
A=list(map(int,input().split()))
s=sum(A)
dp=[[-INF]*(s+1) for i in range(N+1)]
dp[0][0]=1000
for i in range(N):
    for j in range(s+1):
        if dp[i][j]==-INF:
            continue
        for x in range(j+1):
            dp[i+1][j-x]=max(dp[i+1][j-x],dp[i][j]+A[i]*x)
        for x in range(dp[i][j]//A[i]+1):
            dp[i+1][j+x]=max(dp[i+1][j+x],dp[i][j]-A[i]*x)
print(max(dp[N]))