#include <bits/stdc++.h>
using namespace std;
long long n, v[2001], dp[81][10001], ans;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> v[i];
    for (int j = 0; j <= 10000; j++) dp[i][j] = -1;
  }
  for (int j = 0; j <= 10000; j++) dp[0][j] = -1;
  dp[0][0] = 1000;
  ans = 1000;
  for (int i = 1; i <= n; i++)
    for (int j = 0; j <= 1000; j++) {
      long long maxim = -1;
      for (int poz = 0; poz < i; poz++)
        for (int l = 0; l <= 1000; l++)
          if (dp[poz][l] >= 0) {
            long long val = dp[i - 1][l] - (j - l) * v[i];
            maxim = max(maxim, val);
          }
      dp[i][j] = maxim;
      ans = max(ans, dp[i][j]);
    }
  cout << ans;
  return 0;
}
