#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
template <class T>
using V = vector<T>;
template <class T>
using VV = V<V<T>>;
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }
template <class T, class U>
void chmin(T& t, const U& u) {
  if (t > u) t = u;
}
template <class T, class U>
void chmax(T& t, const U& u) {
  if (t < u) t = u;
}
template <class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}
template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
  os << "{";
  for (int i = 0; i < (v.size()); i++) {
    if (i) os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}
const int MX = 1000;
ll dp[100][MX];
int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  V<int> A(N);
  for (int i = 0; i < (N); i++) cin >> A[i];
  memset(dp, -1, sizeof(dp));
  dp[0][0] = 1000;
  for (int i = 0; i < (N); i++) {
    for (int j = 0; j < (MX); j++)
      if (dp[i][j] != -1) {
        for (int k = 0; k <= j; ++k) {
          chmax(dp[i + 1][k], dp[i][j] + (j - k) * A[i]);
        }
        for (int k = j; k < MX; ++k) {
          if (A[i] * (k - j) > dp[i][j]) break;
          chmax(dp[i + 1][k], dp[i][j] - (k - j) * A[i]);
        }
      }
  }
  ll ans = 0;
  for (int j = 0; j < (MX); j++) chmax(ans, dp[N][j]);
  cout << ans << endl;
  return 0;
}
