INF=float('inf')
N=int(input())
A=list(map(int,input().split()))
dp=[[-INF for i in range(20)] for i in range(N+1)]
dp[0][0]=1000#dp[i][j]=i日目に株をj個持っているときの最大所持金

for i in range(N):
    for j in range(20):
        if dp[i][j]==-INF:
            continue
        dp[i+1][j]=dp[i][j]
        for x in range(1,j+1):
            if j-x>=0:
                dp[i+1][j-x]=max(dp[i][j]+A[i]*x,dp[i+1][j-x])
            else:
                break
        for x in range(1,1000000):
            if dp[i][j]-A[i]*x>=0:
                dp[i+1][j+x]=max(dp[i][j]-A[i]*x,dp[i+1][j+x])
            else:
                break
print(max(dp[N]))