#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T1, class T2>
ostream& operator<<(ostream& s, pair<T1, T2> P) {
  return s << '<' << P.first << ", " << P.second << '>';
}
template <class T>
ostream& operator<<(ostream& s, vector<T> P) {
  for (long long i = 0; i < P.size(); ++i) {
    if (i > 0) {
      s << " ";
    }
    s << P[i];
  }
  return s;
}
template <class T>
ostream& operator<<(ostream& s, vector<vector<T> > P) {
  for (long long i = 0; i < P.size(); ++i) {
    s << endl << P[i];
  }
  return s << endl;
}
template <class T>
ostream& operator<<(ostream& s, set<T> P) {
  for (__typeof__((P).begin()) it = (P).begin(); it != (P).end(); ++it) {
    s << "<" << *it << "> ";
  }
  return s << endl;
}
template <class T1, class T2>
ostream& operator<<(ostream& s, map<T1, T2> P) {
  for (__typeof__((P).begin()) it = (P).begin(); it != (P).end(); ++it) {
    s << "<" << it->first << "->" << it->second << "> ";
  }
  return s << endl;
}
template <class T>
void show(vector<T> v) {
  for (long long i = 0; i < v.size(); i++) {
    cerr << v[i] << " ";
  }
  cerr << "\n";
}
long long dp[100][200 * 80 + 10];
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  long long n;
  cin >> n;
  vector<long long> a(n);
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (long long i = 0; i <= n; i++) {
    for (long long j = 0; j < 200 * 80 + 10; j++) {
      dp[i][j] = -1;
    }
  }
  dp[0][1000] = 0;
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < 200 * 80 + 10; j++) {
      if (dp[i][j] == -1) continue;
      long long k = 0;
      while (1) {
        if (j - a[i] * (k) < 0) {
          break;
        }
        dp[i + 1][j - a[i] * (k)] = k + dp[i][j];
        k++;
      }
      if (dp[i][j] >= 1) {
        for (long long k = 0; k <= dp[i][j]; k++) {
          dp[i + 1][j + a[i] * (k)] = dp[i][j] - k;
        }
      }
    }
  }
  long long ans = 0;
  for (long long i = 0; i <= n; i++) {
    for (long long j = 0; j < 200 * 80 + 10; j++) {
      if (dp[i][j] >= 0) {
        chmax(ans, j);
      }
    }
  }
  cout << ans << endl;
  return 0;
}
