#include <bits/stdc++.h>   using namespace std;   const int maxn = 1 + 9e6;   const int inf = 0x3f3f3f;   vector<bool> dp[24];   int n;   int a[23];   vector<pair<int, int> > pre[23];   int ans;   int main() {     ios_base::sync_with_stdio(0);     cin.tie();     cout.tie();     cin >> n;     for (int i = 0; i < n; ++i) {       cin >> a[i];     }     for (int i = 0; i < 24; i++) dp[i].resize(1 << n);     for (int i = 1; i < n; ++i) {       for (int j = 0; j < i; ++j) {         for (int k = j; k < i; ++k) {           if (a[j] + a[k] == a[i]) {             pre[i].push_back({j, k});           }         }       }     }     dp[0][0] = 0;     dp[0][1] = 1;     for (int i = 0; i < n - 1; ++i) {       for (int mask = 0; mask < (1 << n); ++mask) {         if (dp[i][mask]) {           for (int j = 0; j < pre[i + 1].size(); ++j) {             int u = pre[i + 1][j].first;             int v = pre[i + 1][j].second;             if (((mask >> u) & 1) && ((mask >> v) & 1)) {               int bit = mask + (1 << (i + 1));               dp[i + 1][bit] = 1;               for (int k = 0; k < i + 1; ++k) {                 if (((bit >> k) & 1)) {                   dp[i + 1][bit ^ (1 << k)] = 1;                 }               }             }           }         }       }     }     ans = inf;     for (int mask = 0; mask < (1 << n); ++mask) {       if (dp[n - 1][mask]) {         ans = min(ans, (int)(__builtin_popcount(mask)));       }     }     if (ans == inf)       cout << -1;     else       cout << ans;     return 0;   }   