#include <bits/stdc++.h>
inline long long read() {
  char cc = getchar();
  long long cn(0), flus(1);
  while (cc < '0' || cc > '9') {
    if (cc == '-') flus = -flus;
    cc = getchar();
  }
  while (cc >= '0' && cc <= '9') {
    cn = cn * 10 + cc - 48;
    cc = getchar();
  }
  return cn * flus;
}
const long long MAXN = 5e3 + 10;
const long long Mod = 998244353, G = 3;
long long a[MAXN], dp[MAXN][MAXN];
signed main() {
  long long n = read();
  for (register long long i = 1; i <= n; ++i) a[i] = read();
  memset(dp, -0x3f, sizeof(dp));
  dp[0][0] = 1000;
  for (register long long i = 1; i <= n; ++i) {
    for (register long long j = 0; j <= 5000; ++j) {
      dp[i][j] = dp[i - 1][j];
      for (register long long k = 0; k <= 5000; ++k) {
        if (dp[i - 1][k] - (j - k) * a[i] > dp[i][j] && dp[i - 1][k] >= 0) {
          dp[i][j] = dp[i - 1][k] - (j - k) * a[i];
        }
        if (dp[i - 1][k] - (j - k) * a[i] < 0) break;
      }
      if (dp[i][j] < 0) break;
    }
  }
  printf("%lld\n", dp[n][0]);
  return 0;
}
