#include <bits/stdc++.h>
using namespace std;
const long long LINF = 1e18;
const int INF = 1e9;
int main() {
  int n;
  cin >> n;
  vector<vector<vector<int>>> g(
      n + 1, vector<vector<int>>(5000, vector<int>(10000, -1)));
  g[0][0][1000] = 1;
  vector<queue<pair<int, int>>> q(n + 1);
  q[0].push({0, 1000});
  for (int i = 0; i < n; ++i) {
    int price;
    cin >> price;
    while (!q[i].empty()) {
      int j = q[i].front().first;
      int l = q[i].front().second;
      q[i].pop();
      for (int k = 0; k <= l / price; ++k) {
        if (g[i + 1][j + k][l - (k * price)] != 1) {
          q[i + 1].push({j + k, l - (k * price)});
          g[i + 1][j + k][l - (k * price)] = 1;
        }
      }
      for (int k = 0; k <= j; ++k) {
        if (g[i + 1][j - k][l + (price * k)] != 1) {
          g[i + 1][j - k][l + (price * k)] = 1;
          q[i + 1].push({j - k, l + (price * k)});
        }
      }
    }
  }
  int ans = 0;
  for (int j = 0; j < 50; ++j) {
    for (int l = 0; l < 2000; ++l) {
      if (g[n][j][l] == 1) {
        ans = max(l, ans);
      }
    }
  }
  cout << ans << endl;
  return 0;
}
