#include <bits/stdc++.h>
using namespace std;
void debug(vector<vector<long long> > &dp, long long k) {
  cout << "New\n";
  for (long long i = 1; i < dp.size(); i++) {
    cout << "Day " << i << " ";
    for (long long j = 0; j < k; j++) {
      if (dp[i][j] == INT_MIN)
        cout << "m ";
      else
        cout << dp[i][j] << " ";
    }
    cout << "\n";
  }
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long n;
  cin >> n;
  vector<long long> stock(n + 1);
  for (long long i = 1; i <= n; i++) cin >> stock[i];
  vector<vector<long long> > dp(n + 1, vector<long long>(20, INT_MIN));
  dp[0][0] = 1000;
  dp[1][0] = 1000;
  long long col = dp[0].size();
  for (long long i = 1; i < col; i++) {
    if (dp[1][0] - stock[1] * i < 0) break;
    dp[1][i] = dp[1][0] - stock[1] * i;
  }
  for (long long i = 2; i <= n; i++) {
    for (long long j = 0; j < col; j++) {
      dp[i][j] = dp[i - 1][j];
      for (long long k = 0; k <= j; k++) {
        dp[i][j] = max(dp[i][j], dp[i - 1][j - k] - stock[i] * k);
      }
      for (long long k = 0; j + k < col; k++) {
        if (dp[i - 1][j + k] < 0) break;
        dp[i][j] = max(dp[i][j], dp[i - 1][j + k] + stock[i] * k);
      }
    }
  }
  cout << dp[n][0] << "\n";
  return 0;
}
