#include <bits/stdc++.h>
using namespace std;
const int S = 1 << 21;
char p0[S], *p1, *p2;
inline int read() {
  static int x, c;
  x = 0;
  do {
    c = (p2 == p1 && (p2 = (p1 = p0) + fread(p0, 1, S, stdin)) == p1 ? EOF
                                                                     : *p1++);
  } while (!isdigit(c));
  do {
    x = (x << 3) + (x << 1) + (c & 15);
    c = (p2 == p1 && (p2 = (p1 = p0) + fread(p0, 1, S, stdin)) == p1 ? EOF
                                                                     : *p1++);
  } while (isdigit(c));
  return x;
}
const long long N = 85;
long long n, a[N], f[N][1005];
signed main() {
  scanf("%lld", &n);
  for (long long i = 1; i <= n; ++i) scanf("%lld", a + i);
  memset(f, -0x3f, sizeof f);
  f[0][0] = 1000;
  for (long long i = 1; i <= n; ++i)
    for (long long j = 0; j <= 800; ++j) {
      for (long long k = 0; k <= j; ++k)
        if (f[i - 1][k] >= a[i] * (j - k))
          f[i][j] = max(f[i][j], f[i - 1][k] - a[i] * (j - k));
      for (long long k = j + 1; k <= 800; ++k)
        f[i][j] = max(f[i][j], f[i - 1][k] + a[i] * (k - j));
    }
  long long ans = 1000;
  for (long long i = 0; i <= 800; ++i) ans = max(ans, f[n][i] + i * a[n]);
  printf("%lld\n", ans);
  return 0;
}
