#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<long long, long long>;
template <class T>
using vec = vector<T>;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n;
  cin >> n;
  vec<ll> a(n);
  ;
  for (long long i = 0; i < (n); i++) cin >> a[i];
  ll dp[100][10000];
  ;
  for (long long i = 0; i < (100); i++) {
    ;
    for (long long j = 0; j < (10000); j++) dp[i][j] = -1;
  }
  dp[0][0] = 1000;
  ;
  for (long long i = 0; i < (n); i++) {
    ;
    for (long long j = 0; j < (10000); j++) {
      if (dp[i][j] == -1) break;
      dp[i + 1][0] = max(dp[i + 1][0], dp[i][j] + j * a[i]);
    };
    for (long long j = 0; j < (9999); j++) {
      if (dp[i][j + 1] < 0 && dp[i + 1][j] < a[i]) break;
      dp[i + 1][j + 1] = max(dp[i][j + 1], dp[i + 1][j] - a[i]);
    }
  }
  cout << dp[n][0] << '\n';
}
