#include <bits/stdc++.h>
using namespace std;
FILE *in;
FILE *out;
int main(void) {
  in = stdin;
  out = stdout;
  int n;
  fscanf(in, "%d", &n);
  map<int, int> q;
  for (int i = 0; i < n; i++) {
    int tmp;
    fscanf(in, "%d", &tmp);
    if (tmp == 0) continue;
    if (q.find(tmp) == q.end()) q[tmp] = 0;
    q[tmp]++;
  }
  int ans = 0;
  for (map<int, int>::iterator it = q.begin(); it != q.end(); it++) {
    if (it->second > 2) {
      ans = -1;
      break;
    }
    if (it->second == 2) ans++;
  }
  fprintf(out, "%d\n", ans);
  return 0;
}
