N=int(input())
alist=list(map(int,input().split()))

#dp[d][kabu]=max(money)
dp=[[-float("inf")]*1001 for _ in range(N+1)]
dp[0][0]=1000

for i in range(1,N+1):
  for j in range(1001):
    dp[i][j]=dp[i-1][j]
    for k in range(1,1001):
      #dp[i][j]=max(dp[i][j],dp[i-1][j-1]-alist[i-1])
      if j-k>=0 and dp[i-1][j-k]-k*alist[i-1]>=0:
        #buy k
        dp[i][j]=max(dp[i][j],dp[i-1][j-k]-k*alist[i-1])
      if j+k<=1000:
        # sell k
        dp[i][j]=max(dp[i][j],dp[i-1][j+k]+k*alist[i-1])
        
answer=0
for j in range(1001):
  answer=max(answer,dp[N][j])

print(answer)