#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
int dx[] = {1, 1, 0, -1, -1, -1, 0, 1};
int dy[] = {0, 1, 1, 1, 0, -1, -1, -1};
long long POW(long long x, long long y) {
  long long ans = 1;
  long long base = x;
  while (y) {
    if (y & 1) {
      ans *= base;
    }
    base = base * base;
    y = y >> 1;
  }
  return ans;
}
const long long M = 1000;
long long dp[81][M + 1] = {0};
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  long long n, i, j, k, t, temp, tc;
  cin >> n;
  const long long INF = 10000000000000000;
  for (i = 0; i <= n; i++) {
    for (j = 0; j <= M; j++) {
      dp[i][j] = -INF;
    }
  }
  dp[0][0] = 1000;
  long long cost[n + 1];
  for (i = 1; i <= n; i++) {
    cin >> cost[i];
  }
  for (i = 1; i <= n; i++) {
    for (j = 0; j <= M; j++) {
      long long curr_maxima = -INF;
      for (k = 0; k <= M; k++) {
        long long consider = -INF;
        if (j == k) {
          consider = dp[i - 1][k];
        } else if (k < j) {
          long long extra = j - k;
          if (dp[i - 1][k] >= 0) {
            if (dp[i - 1][k] - cost[i] * extra >= 0) {
              consider = dp[i - 1][k] - cost[i] * extra;
            }
          }
        } else {
          long long extra = k - j;
          if (dp[i - 1][k] >= 0 - INF) {
            consider = dp[i - 1][k] + cost[i] * extra;
          }
        }
        dp[i][j] = max(dp[i][j], consider);
      }
    }
  }
  long long ans = -1;
  for (i = 0; i <= M; i++) {
    ans = max(ans, dp[n][i]);
  }
  cout << ans << endl;
  return 0;
}
