#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
int n, a[N];
int dp[88][3333];
int main() {
  ios::sync_with_stdio(false);
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  memset(dp, -0x3f3f3f3f, sizeof dp);
  dp[0][0] = 1000;
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = 500; j >= 0; j--) {
      for (int k = 0; k <= 500; k++) {
        if (j <= k)
          dp[i][j] = max(dp[i - 1][k] + (k - j) * a[i], dp[i][j]);
        else {
          if ((j - k) * a[i] <= dp[i - 1][k])
            dp[i][j] = max(dp[i][j], dp[i - 1][k] - (j - k) * a[i]);
        }
        ans = max(ans, dp[i][j]);
      }
    }
  }
  cout << ans << '\n';
  return 0;
}
