#include <bits/stdc++.h>
using namespace std;
long long int a[100], dp[100][3000], hell = 5 * pow(10, 14);
void solve() {
  long long int n;
  cin >> n;
  for (long long int i = 1; i <= n; i++) cin >> a[i];
  for (long long int i = 0; i < 100; i++)
    for (long long int j = 0; j < 3000; j++) dp[i][j] = (-hell);
  dp[0][0] = 1000;
  for (long long int i = 1; i <= n; i++) {
    for (long long int j = 0; j < 3000; j++)
      for (long long int k = 0; k < 3000; k++)
        if (k >= j || dp[i - 1][k] >= (j - k) * a[i])
          dp[i][j] = max(dp[i][j], dp[i - 1][k] + (k - j) * a[i]);
  }
  long long int res = 0;
  for (long long int i = 0; i < 3000; i++) res = max(res, dp[n][i]);
  cout << res;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int qc = 1;
  for (long long int i = 1; i <= qc; i++) solve();
}
