#include <bits/stdc++.h>
using namespace std;
const int Maxn = 2100000;
const int inf = 0x3f3f3f3f;
int f[100][110], n, a[Maxn];
signed main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (int i = 0; i <= n; i++)
    for (int j = 1; j <= 100; j++) f[i][j] = -inf;
  f[0][0] = 1000;
  for (int i = 1; i <= n; i++)
    for (int j = 0; j <= 100; j++)
      for (int k = 0; k <= 100; k++)
        if (j > k)
          (f[i][k] = max(f[i][k], f[i - 1][j] + a[i] * (j - k)));
        else if (f[i - 1][j] >= (k - j) * a[i])
          (f[i][k] = max(f[i][k], f[i - 1][j] + a[i] * (j - k)));
  printf("%d\n", f[n][0]);
  return 0;
}
