#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1LL << 60;
long long mod_pow(long long, long long, long long);
long long mod_fact(long long, long long);
long long mod_inv(long long, long long);
long long gcd(long long, long long);
long long lcm(long long, long long);
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  vector<vector<int>> dp(n + 1, vector<int>(20000, -1));
  dp[0][1000] = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 20000; j++) {
      if (dp[i][j] >= 0) {
        dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);
        int k = j - a[i];
        while (k >= 0) {
          dp[i + 1][k] = max(dp[i + 1][k], dp[i][j] + (j - k) / a[i]);
          k -= a[i];
        }
        int t = dp[i][j];
        for (int l = 1; l <= t; l++) {
          dp[i][j + l * a[i]] = max(dp[i][j + l * a[i]], dp[i][j] - l);
        }
      }
    }
  }
  for (int i = 19999; i >= 0; i--) {
    if (dp[n][i] >= 0) {
      cout << i << "\n";
      break;
    }
  }
}
