#include <bits/stdc++.h>
using namespace std;
int a[5000010], n, vis[1 << (23)];
int dfs(int now) {
  if (vis[now]) return vis[now];
  if (now == 1) return 1;
  int ret = 100;
  int temp = __builtin_popcount(now);
  for (int i = n - 1; i >= 0; i--)
    if (now & (1 << i)) {
      int next = (now ^ (1 << i)) | (1 << (i - 1));
      for (int j = 0; j < i; j++)
        for (int k = 0; k <= j; k++)
          if (a[j] + a[k] == a[i]) {
            int tp = dfs(next | (1 << j) | (1 << k));
            ret = min(ret, max(temp, tp));
          }
      break;
    }
  return vis[now] = ret;
}
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  memset(vis, 0, sizeof(vis));
  int ans = dfs(1 << (n - 1));
  if (ans == 100) ans = -1;
  cout << ans << endl;
  return 0;
}
