#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;

int n, a[81];
long long dp[81][501];

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> n;
	for(int i = 1; i <= n; i++) cin >> a[i];
	fill(dp[0], dp[0] + 81 * 501, -1);
	dp[0][0] = 1000;
	for(int i = 1; i <= n; i++)
		for(int j = 0; j <= 500; j++){
			dp[i][j] = dp[i - 1][j];
			if(j < 500) for(int k = j + 1; k <= 500; k++)
				if(dp[i - 1][k] != -1)
					dp[i][j] = max(dp[i][j], dp[i - 1][k] + a[i] * (k - j));
			if(j > 0) for(int k = 0; k < j; k++)
				if(dp[i - 1][k] != -1 && dp[i - 1][k] - a[i] * (j - k) >= 0)
					dp[i][j] = max(dp[i][j], dp[i - 1][k] - a[i] * (j - k));
		}
	cout << dp[n][0] << '\n';
	return 0;
}