#include <bits/stdc++.h>
using namespace std;
unordered_map<int, int> dp[85];
int main() {
  int N;
  cin >> N;
  vector<int> v;
  for (int i = (0); i < (int)(N); i++) {
    int a;
    cin >> a;
    v.push_back(a);
  }
  dp[0][1000] = 0;
  for (int i = (0); i < (int)(N); i++) {
    for (__typeof((dp[i]).begin()) it = (dp[i]).begin(); it != (dp[i]).end();
         ++it) {
      int money = it->first;
      int kabu = it->second;
      { dp[i + 1][money] = kabu; }
      {
        int j = 1;
        while (money - v[i] * j >= 0) {
          dp[i + 1][money - v[i] * j] =
              max(dp[i + 1][money - v[i] * j], kabu + j);
          j++;
        }
      }
      {
        int j = 1;
        while (kabu - j >= 0) {
          dp[i + 1][money + v[i] * j] =
              max(dp[i + 1][money + v[i] * j], kabu - j);
          j++;
        }
      }
    }
  }
  int ret = 0;
  for (__typeof((dp[N]).begin()) it = (dp[N]).begin(); it != (dp[N]).end();
       ++it) {
    ret = max(ret, it->first);
  }
  cout << ret << endl;
  return 0;
}
