#include <bits/stdc++.h>
using namespace std;
template <class RandomAccessIterator>
size_t indexOf(RandomAccessIterator begin, RandomAccessIterator end,
               typename RandomAccessIterator::value_type value) {
  return distance(begin, lower_bound(begin, end, value));
}
int countOnes(int n) {
  int ret = 0;
  while (n > 0) {
    ret += n & 1;
    n >>= 1;
  }
  return ret;
}
void solve() {
  static const int UNDEFINED = -1;
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < int(n); ++i) cin >> a[i];
  vector<int> uniq((a).begin(), (a).end());
  sort((uniq).begin(), (uniq).end());
  vector<vector<int> > addId(n, vector<int>(n, UNDEFINED));
  for (int i = 0; i < int(n); ++i) {
    for (int j = 0; j < int(n); ++j) {
      int id = indexOf((uniq).begin(), (uniq).end(), uniq[i] - uniq[j]);
      if (id < n && uniq[id] == uniq[i] - uniq[j]) {
        addId[i][j] = id;
      }
    }
  }
  vector<bool> d(1 << n);
  d[1] = true;
  queue<pair<int, int> > q;
  q.push(make_pair(1, 1));
  while (!q.empty()) {
    pair<int, int> state = q.front();
    q.pop();
    if (state.second >= n) continue;
    int id = indexOf((uniq).begin(), (uniq).end(), a[state.second]);
    assert(id < n);
    int mask = state.first;
    bool canBeObtained = false;
    for (int i = 0; i < int(n); ++i) {
      if (!((1 << i) & mask)) continue;
      int j = addId[id][i];
      canBeObtained = (j < n && ((1 << j) & mask));
      if (canBeObtained) break;
    }
    if (!canBeObtained) continue;
    int nmask = mask | (1 << id);
    if (!d[nmask]) {
      d[nmask] = true;
      q.push(make_pair(nmask, state.second + 1));
    }
    for (int i = 0; i < int(n); ++i) {
      if (!((1 << i) & mask)) continue;
      int nmask = (mask ^ (1 << i)) | (1 << id);
      if (!d[nmask]) {
        d[nmask] = true;
        q.push(make_pair(nmask, state.second + 1));
      }
    }
  }
  int ans = UNDEFINED;
  int lastId = indexOf((uniq).begin(), (uniq).end(), a.back());
  for (int mask = 0; mask < int(1 << n); ++mask) {
    if (d[mask] && (mask & (1 << lastId))) {
      if (ans == UNDEFINED)
        ans = countOnes(mask);
      else
        ans = min(ans, countOnes(mask));
    }
  }
  cout << ans << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  solve();
  return 0;
}
