#include <bits/stdc++.h>
using namespace std;
int recur_depth = 0;
template <typename Ostream, typename Cont>
typename enable_if<is_same<Ostream, ostream>::value, Ostream&>::type operator<<(
    Ostream& os, const Cont& v) {
  os << "[";
  for (auto& x : v) {
    os << x << ", ";
  }
  return os << "]";
}
template <typename Ostream, typename... Ts>
Ostream& operator<<(Ostream& os, const pair<Ts...>& p) {
  return os << "{" << p.first << ", " << p.second << "}";
}
const int INF = 1e9;
void solve() {
  long long int n;
  cin >> n;
  long long int a[n];
  for (int i = 0; i < n; i++) cin >> a[i];
  long long int dp[n + 1][200][2];
  memset(dp, -1, sizeof(dp));
  dp[0][0][0] = dp[0][0][1] = 1000;
  long long int ans = 1000;
  for (long long int i = 1; i <= n; i++) {
    for (long long int j = 0; j < 12; j++) {
      for (long long int l = 0; l <= j; l++) {
        long long int sbuy = j - l;
        long long int aspent = INF;
        if (dp[i - 1][l][0] == -1 && dp[i - 1][l][1] == -1) continue;
        if (sbuy * a[i - 1] <= dp[i - 1][l][0]) {
          aspent = sbuy * a[i - 1];
        }
        if (sbuy * a[i - 1] <= dp[i - 1][l][1]) aspent = sbuy * a[i - 1];
        if (aspent >= INF) continue;
        long long int left = max(dp[i - 1][l][0], dp[i - 1][l][1]) - aspent;
        dp[i][j][1] = max(dp[i][j][1], left);
        ans = max(ans, dp[i][j][1]);
      }
      for (long long int l = j; l < 12; l++) {
        long long int sell = l - j;
        long long int earn = INF;
        if (dp[i - 1][l][0] == -1 && dp[i - 1][l][1] == -1) continue;
        earn = sell * a[i - 1];
        long long int total = max(dp[i - 1][l][0], dp[i - 1][l][1]) + earn;
        dp[i][j][0] = max(dp[i][j][0], total);
        ans = max(ans, dp[i][j][0]);
      }
    }
  }
  cout << ans << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  ;
  solve();
}
