#include <bits/stdc++.h>
using namespace std;
const int N = 85, M = 205;
int dp[N][M];
int n, a[N], sum = 0;
int main() {
  scanf("%d", &n);
  memset(dp, -0x3f3f3f, sizeof(dp));
  dp[0][0] = 1000;
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &a[i]);
    for (int j = 0; j <= i + 20; ++j) {
      dp[i][j] = dp[i - 1][j];
      for (int k = 0; k < j; ++k) {
        if (dp[i - 1][k] >= (a[i] * (j - k))) {
          dp[i][j] = max(dp[i][j], dp[i - 1][k] - a[i] * (j - k));
        }
      }
      for (int k = j + 1; k <= i + 20; ++k) {
        dp[i][j] = max(dp[i][j], dp[i - 1][k] + a[i] * (k - j));
      }
    }
  }
  for (int i = 0; i <= n; ++i) {
    sum = max(sum, dp[n][i]);
  }
  printf("%d\n", sum);
  return 0;
}
