#include <bits/stdc++.h>
using namespace std;
long long n, v[2001], dp[81][10001];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> v[i];
    for (int j = 0; j <= 10000; j++) dp[i][j] = -1;
  }
  for (int j = 0; j <= 10000; j++) dp[0][j] = -1;
  dp[0][0] = 1000;
  for (int i = 1; i <= n; i++)
    for (int j = 0; j <= 1000; j++) {
      long long maxim = -1;
      for (int l = 0; l <= 1000; l++)
        if (dp[i - 1][l] != -1) {
          long long val = dp[i - 1][l];
          if (l <= j) {
            val = dp[i - 1][l] - (j - l) * v[i];
            if (val < 0) val = -1;
          } else {
            val = dp[i - 1][l] + (l - j) * v[i];
            if (val < 0) val = -1;
          }
          if (maxim == -1)
            maxim = val;
          else
            maxim = max(maxim, val);
        }
      dp[i][j] = maxim;
    }
  cout << dp[n][0];
  return 0;
}
