#include <bits/stdc++.h>
using namespace std;
inline int read() {
  register int x = 0, flag = 1;
  register char ch;
  while (!isdigit(ch = getchar()))
    if (ch == '-') flag = -1;
  while (x = x * 10 + (ch & 15), isdigit(ch = getchar()))
    ;
  return x * flag;
}
template <class T>
inline void write(T x) {
  if (x < 0) putchar('-'), x = -x;
  if (x >= 10) write(x / 10);
  putchar(x % 10 + '0');
}
template <class T>
inline bool Chkmax(T& x, const T& y) {
  return x < y ? x = y, true : false;
}
template <class T>
inline bool Chkmin(T& x, const T& y) {
  return x > y ? x = y, true : false;
}
const int maxn = 100;
int n;
int a[maxn];
int dp[maxn][1010], yes[maxn][1100];
int main() {
  n = read();
  for (int i = 1; i <= n; i++) {
    a[i] = read();
  }
  memset(dp, -0x3f, sizeof(dp));
  dp[0][0] = 1000;
  yes[0][0] = 1;
  for (int i = 1; i <= n; i++) {
    for (int p = 0; p <= 1000; p++) {
      for (int k = 0; k <= p; k++) {
        if (dp[i - 1][p - k] >= k * a[i] && yes[i - 1][p - k] == 1)
          yes[i][p] = 1, dp[i][p] = max(dp[i][p], dp[i - 1][p - k] - k * a[i]);
      }
      for (int k = 0; k <= 1000; k++) {
        if (yes[i - 1][p + k] == 1)
          yes[i][p] = 1, dp[i][p] = max(dp[i][p], dp[i - 1][p + k] + k * a[i]);
      }
    }
  }
  int maxx = 0;
  for (int i = 0; i <= 1000; i++) {
    if (yes[n][i]) maxx = max(maxx, dp[n][i]);
  }
  cout << maxx << endl;
  return 0;
}
