#include <bits/stdc++.h>
using namespace std;
long long a[85], d[105][30];
int main() {
  long long n;
  cin >> n;
  for (long long i = 1; i <= n; i++) {
    cin >> a[i];
  }
  for (long long i = 0; i <= n; i++) {
    for (long long j = 0; j <= 20; j++) {
      d[i][j] = -1e7;
    }
  }
  d[0][0] = 1000;
  for (long long i = 1; i <= n; i++) {
    for (long long j = 0; j <= 20; j++) {
      for (long long k = 0; k <= 20; k++) {
        if (j > k && d[i - 1][k] - (j - k) * a[i] >= 0)
          d[i][j] = max(d[i][j], d[i - 1][k] - (j - k) * a[i]);
        if (j <= k && d[i - 1][k] >= 0)
          d[i][j] = max(d[i][j], d[i - 1][k] + (k - j) * a[i]);
      }
    }
  }
  cout << d[n][0] << endl;
}
