n = int(input())
a = list(map(int, input().split()))

dp = [[-1]*n for i in range(100)]
for i in range(1000//a[0]+1):
    dp[i][0] = 1000-a[0]*i

for i in range(1, n):
    for g in range(100):
        for l in range(100):
            if dp[l][i-1] >= 0:
                if l < g:
                    dp[g][i] = max(dp[l][i-1] - a[i]*(g-l), dp[g][i])
                else:
                    dp[g][i] = max(dp[l][i-1] + a[i]*(l-g), dp[g][i])
            else:
                break


ans = 0
for m in range(100):
    ans = max(ans, dp[m][n-1])
print(ans)
