#include <bits/stdc++.h>
using namespace std;
const int N = 1000, bs = 500;
const long long inf = 1e7;
const double EPS = 0.000001;
int n;
long long a[N], dp[120][N + 123], bg = 1000;
long long f[N + 100];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long res = 1000;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j <= N; j++) {
      dp[i][j] = -inf;
      f[j] = -inf;
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j <= N; j++) {
      if (bg - j * a[i] >= 0) {
        dp[i][j] = max(dp[i][j], bg - j * a[i]);
      }
      for (int k = 0; k <= N; k++) {
        if (f[k] + (k - j) * a[i] >= 0)
          dp[i][j] = max(dp[i][j], f[k] + (k - j) * a[i]);
      }
    }
    for (int j = 0; j <= N; j++) {
      if (dp[i][j] >= 0) f[j] = max(f[j], dp[i][j]);
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j <= N; j++) {
      res = max(res, dp[i][j] + j * a[i]);
    }
  }
  cout << res;
}
