#include <bits/stdc++.h>
using namespace std;
int dp[1 << 24];
int n, a[30];
int dfs(int state, int p) {
  int v;
  if (dp[state]) return dp[state];
  v = __builtin_popcount(state);
  int ret = 1e9;
  for (int i = 0; i < p; i++) {
    for (int j = 0; j <= i; j++) {
      if (a[i] + a[j] != a[p]) continue;
      int tmp =
          dfs(state ^ (1 << p) | (1 << (p - 1)) | (1 << i) | (1 << j), p - 1);
      ret = min(ret, max(v, tmp));
    }
  }
  return dp[state] = ret;
}
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  dp[1] = 1;
  int ans = dfs(1 << (n - 1), n - 1);
  if (ans == 1e9) ans = -1;
  cout << ans << endl;
  return 0;
}
