#include <bits/stdc++.h>
using namespace std;
int a[24], n, Z[24];
bool DP[24][(1 << 23) + 5];
vector<int> X;
map<int, int> Memo;
int main() {
std:
  ios::sync_with_stdio(false);
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    Memo[a[i]] = i + 1;
  }
  Z[0] = 1;
  DP[0][0] = 1;
  for (int i = 1; i < n; i++) {
    int b = 1 << i;
    for (int j = 1; j < b; j++) {
      if (j & (1 << (i - 1))) {
        int cnt = 0, ch = 0;
        for (int k = 0; k < i; k++) {
          if (j & 1 << k) {
            int P = a[i] - a[k];
            if (Memo[P] != 0) {
              if (j & 1 << (Memo[P] - 1)) ch = 1;
            }
            cnt++;
          }
        }
        if (ch == 1) {
          int mmask = j & (~(1 << (i - 1)));
          if (DP[i - 1][mmask] == 1) ch = 2;
          for (int k = 0; k < i - 1; k++) {
            if (!(mmask & 1 << k)) {
              int mask = 1 << k;
              mask = mask | mmask;
              if (DP[i - 1][mask] == 1) ch = 2;
            }
          }
        }
        if (ch == 2) {
          DP[i][j] = 1;
          if (cnt < Z[i] || Z[i] == 0) Z[i] = cnt;
        }
      }
    }
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (Z[i] == 0) {
      cout << "-1\n";
      return 0;
    }
    if (ans < Z[i]) ans = Z[i];
  }
  cout << ans << endl;
}
