import sys
sys.setrecursionlimit(10**9)

def mi(): return map(int,input().split())
def ii(): return int(input())
def isp(): return input().split()
def deb(text): print("-------\n{}\n-------".format(text))

INF=10**20
def main():
    N=ii()
    A=list(mi()) + [0]

    dp = [[0] * (2*10**5+10) for _ in range(N+1)]
    x = 1000//A[0]
    dp[0][x] = 1000 - x * A[0]


    for i in range(x):
        dp[0][i] = 1000 - i * A[0]

    mx = x
    for i in range(N):
        _mx = mx
        for m in range(mx+1):
            for n in range(m+1):
                dp[i+1][m-n] = max(0,dp[i+1][m-n],dp[i][m] + A[i+1] * n)
                # assert dp[i+1][m-n] >= 0
            
            if A[i+1] != 0:
                for j in range((dp[i][m] // A[i+1])+1):
                    dp[i+1][m+j] = max(0,dp[i+1][m+j],dp[i][m] - A[i+1] * j)
                    _mx = max(_mx,m+j)
                    
                    # assert dp[i+1][m+j] >= 0

        mx = _mx

    ans = 0
    for i in range(len(dp[N-1])):
        if dp[N-1][i] == 0: continue
        ans = max(ans, dp[N-1][i] + A[N-1] * i)

    # print(dp[3][10])
    print(ans)

if __name__ == "__main__":
    main()