#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const int INF = 1e9;
void print() {}
template <class H, class... T>
void print(H&& h, T&&... t) {
  cout << h << " \n"[sizeof...(t) == 0];
  print(forward<T>(t)...);
}
ll dp[85][100010] = {};
void solve() {
  ll N;
  cin >> N;
  ll A[85];
  for (ll i = (0); i < (N); i++) cin >> A[i];
  for (ll i = (0); i < (N + 1); i++) {
    for (ll j = (0); j < (100001); j++) {
      dp[i][j] = -INF;
    }
  }
  dp[0][1000] = 0;
  for (ll i = (0); i < (N); i++) {
    for (ll j = (0); j < (100001); j++) {
      if (dp[i][j] == -INF) continue;
      ll num = dp[i][j];
      for (ll sell = (0); sell < (num + 1); sell++) {
        int money = sell * A[i];
        dp[i + 1][j + money] = max(dp[i + 1][j + money], dp[i][j] - sell);
      }
      for (ll buy = (0); buy < (110); buy++) {
        int money = buy * A[i];
        if (j < money) break;
        dp[i + 1][j - money] = max(dp[i + 1][j - money], dp[i][j] + buy);
      }
    }
  }
  for (ll i = (100000); i >= (0); i--) {
    if (dp[N][i] >= 0) {
      print(i);
      return;
    }
  }
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  solve();
}
