#include <bits/stdc++.h>
using namespace std;
const double EPS = 1e-9;
const int INF = int(2e9);
const long long LINF = long long(2e9) * long long(2e9);
template <class T, class C>
void chmax(T& a, C b) {
  a > b ?: a = b;
}
template <class T, class C>
void chmin(T& a, C b) {
  a < b ?: a = b;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int N;
  cin >> N;
  vector<long long> A(N);
  for (int i = 0; i < N; i++) cin >> A[i];
  vector<vector<long long>> dp(N + 1, vector<long long>(5001, -1));
  vector<vector<bool>> dp2(N + 1, vector<bool>(5001, false));
  dp[0][0] = 1000;
  dp2[0][0] = true;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < 5001; j++) {
      long long k = 0;
      while (1) {
        if (dp[i][j] >= A[i] * k) {
          dp2[i + 1][j + k] = true;
          dp[i + 1][j + k] = max(dp[i + 1][j + k], dp[i][j] - A[i] * k);
        } else {
          break;
        }
        k++;
      }
      if (dp2[i][j] == true) {
        for (k = 0; k <= j; k++) {
          if (dp[i + 1][j - k] < dp[i][j] + A[i] * k) {
            dp[i + 1][j - k] = dp[i][j] + A[i] * k;
            dp2[i + 1][j] = false;
            dp2[i + 1][j - k] = true;
          } else {
            dp2[i + 1][j - k] = dp[i + 1][j - k];
            dp2[i + 1][j - k] = true;
          }
        }
      }
    }
  }
  long long ans = 0;
  for (int i = 0; i < 5001; i++) {
    ans = max(ans, dp[N][i]);
  }
  cout << ans << endl;
  return 0;
}
