#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
ll dp[90][400];
int a[90];
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 0; i < (90); i++)
    for (int j = 0; j < (400); j++) dp[i][j] = -1001001001;
  dp[0][0] = 1000;
  for (int i = 0; i < (n); i++) {
    for (int j = 0; j < (400); j++) {
      for (int k = 0; k <= j; k++) {
        if (dp[i][j - k] >= k * a[i + 1])
          dp[i + 1][j] = max(dp[i + 1][j], dp[i][j - k] - k * a[i + 1]);
      }
      for (int m = 399; m >= j; m--) {
        dp[i + 1][j] = max(dp[i + 1][j], dp[i][m] + (m - j) * a[i + 1]);
      }
    }
  }
  cout << dp[n][0] << endl;
  return 0;
}
