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

MAX = 10 ** 6 + 10
dp = [-1] * MAX
dp[0] = 1000
for i in range(N):
    for j in range(1, MAX):
        dp[j] = max(dp[j], dp[j - 1] - X[i])

    for j in reversed(range(MAX - 1)):
        if dp[j + 1] >= 0:
            dp[j] = max(dp[j], dp[j + 1] + X[i])

print(max(dp))
