#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using vecint = vector<int>;
using vecll = vector<ll>;
using vec2int = vector<vector<int>>;
using P = pair<int, int>;
int main() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  vecint a(n);
  for (auto& e : a) cin >> e;
  vector<map<int, int>> mp(n + 1);
  mp[0][1000] = 0;
  for (int i = 0; i < (int)n; i++) {
    for (auto& e : mp[i]) {
      int x = e.first;
      int y = e.second;
      for (int k = 0; x - k * a[i] >= 0; k++) {
        mp[i + 1][x - k * a[i]] = y + k;
      }
      for (int l = 1; l <= y; l++) {
        mp[i + 1][x + l * a[i]] = y - l;
      }
    }
  }
  auto itr = mp[n].end();
  itr--;
  cout << itr->first << endl;
}
