#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  int ans = 1000;
  vector<vector<int>> dp(n, vector<int>(102, -1));
  for (int i = 0; i <= 10; i++) {
    dp[0][i] = ans - a[0] * i;
  }
  for (int i = 1; i < n; i++) {
    for (int j = 0; j <= 100; j++) {
      if (dp[i - 1][j] >= 0) {
        for (int k = 0; k <= 100; k++) {
          dp[i][k] = max(dp[i][k], dp[i - 1][j] + a[i] * (j - k));
        }
      }
    }
  }
  int maxi = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j <= 100; j++) {
      maxi = max(maxi, dp[i][j]);
    }
  }
  cout << maxi << endl;
  return 0;
}
