#include <bits/stdc++.h>
using namespace std;
void check(char c, bool &Xwon, bool &Owon, bool &completed) {
  switch (c) {
    case '.': {
      Xwon = false;
      Owon = false;
      completed = false;
      break;
    }
    case 'O': {
      Xwon = false;
      break;
    }
    case 'X': {
      Owon = false;
      break;
    }
  }
}
int main() {
  long n;
  cin >> n;
  map<long, long> kol;
  for (long i = 0; i < n; i++) {
    long temp;
    cin >> temp;
    kol[temp]++;
  }
  long res = 0;
  bool valid = true;
  for (map<long, long>::iterator it = kol.begin(); it != kol.end(); it++) {
    if (it->first != 0) {
      if (it->second == 2) res++;
      if (it->second > 2) valid = false;
    }
  }
  if (valid)
    cout << res;
  else
    cout << "-1";
}
