#include <bits/stdc++.h>
int a[30], b[30], n, as;
bool f[1 << 25];
void dfs(int x, int d) {
  if (f[x]) return;
  f[x] = 1;
  int i, j, k, top = 0, y;
  for (i = j = 0; i < 25; i++)
    if (x & (1 << i)) j++;
  if (j >= as) return;
  if (n == d) {
    as = j;
    return;
  }
  for (i = 0; i < d; i++)
    if (x & (1 << i)) b[top++] = a[i];
  x |= (1 << d);
  for (i = 0; i < top; i++)
    for (j = i; j < top; j++)
      if (b[i] + b[j] == a[d]) {
        for (k = 0; k < d; k++)
          if (x & (1 << k)) dfs(x ^ (1 << k), d + 1);
        dfs(x, d + 1);
      }
}
int main() {
  int i;
  as = 30;
  scanf("%d", &n);
  for (i = 0; i < n; i++) scanf("%d", &a[i]);
  for (i = 1; i < n; i++) {
    if (a[i] % a[0]) break;
    a[i] /= a[0];
  }
  a[0] = 1;
  if (i < n) {
    puts("-1");
    return 0;
  }
  dfs(1, 1);
  printf("%d\n", as == 30 ? -1 : as);
  return 0;
}
