#include <bits/stdc++.h>
using namespace std;
using ll = long long;
bool dp[85][25][2005];
int n;
vector<int> a;
void solve(int i, int stock, int money) {
  if (dp[i][stock][money]) {
    return;
  }
  dp[i][stock][money] = true;
  if (i == n) {
    return;
  }
  for (int j = 0; j <= money / a[i]; j++) {
    if (money - j * a[i] < 0) continue;
    solve(i + 1, stock + j, money - j * a[i]);
  }
  for (int j = 0; j <= stock; j++) {
    solve(i + 1, stock - j, money + j * a[i]);
  }
}
int main() {
  cin >> n;
  a.resize(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j <= 20; j++) {
      for (int k = 0; k <= 2000; k++) {
        dp[i][j][k] = false;
      }
    }
  }
  solve(0, 0, 1000);
  for (int i = 2000; i >= 1000; i--) {
    for (int j = 0; j <= 20; j++) {
      if (dp[n][j][i]) {
        cout << i << endl;
        return 0;
      }
    }
  }
  return 0;
}
