#include <bits/stdc++.h>
using namespace std;
vector<long long> v;
vector<vector<long long> > dp;
int main() {
  long long n, i, j, k, mx = 0;
  cin >> n;
  dp.resize(n + 1);
  v.resize(n + 1);
  for (i = 0; i < n + 1; i++) dp[i].resize(51, -1);
  for (i = 1; i <= n; i++) cin >> v[i];
  dp[0][0] = 1000;
  for (i = 1; i <= n; i++) {
    for (j = 0; j < 51; j++) {
      for (k = 0; k < 51; k++) {
        if (dp[i - 1][k] >= 0 && k < j) {
          if (v[i] * (j - k) <= dp[i - 1][k])
            dp[i][j] = max(dp[i][j], dp[i - 1][k] - v[i] * (j - k));
        } else if (dp[i - 1][k] >= 0 && k == j) {
          dp[i][j] = max(dp[i][j], dp[i - 1][k]);
        } else if (dp[i - 1][k] >= 0 && k > j) {
          dp[i][j] = max(dp[i][j], dp[i - 1][k] + v[i] * (k - j));
        }
      }
      if (i == n) mx = max(mx, dp[i][j]);
    }
  }
  cout << mx << endl;
  return 0;
}
