#include <bits/stdc++.h>
using namespace std;
const int MAX = 2222;
int a[88], dp[88][MAX + 1];
int main(void) {
  int n, i, j, k;
  scanf("%d", &n);
  for (i = 1; i <= n; i++) scanf("%d", &a[i]);
  memset(dp, -1, sizeof(dp));
  dp[0][0] = 1000;
  for (i = 1; i <= n; i++)
    for (j = 0; j <= MAX; j++)
      for (k = 0; k <= MAX; k++) {
        if (dp[i - 1][k] == -1) continue;
        dp[i][j] = max(dp[i][j], 0);
        if (j < k)
          dp[i][j] = max(dp[i][j], dp[i - 1][k] + (k - j) * a[i]);
        else if (dp[i - 1][k] >= (j - k) * a[i])
          dp[i][j] = max(dp[i][j], dp[i - 1][k] - (j - k) * a[i]);
      }
  int ans = 0;
  for (j = 0; j <= MAX; j++) ans = max(ans, dp[n][j]);
  printf("%d", ans);
  return 0;
}
