#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int p = 0;
  map<int, int> *s = new map<int, int>();
  int id;
  for (int i = 0; i < n; i++) {
    cin >> id;
    if (s->find(id) == s->end())
      (*s)[id] = 1;
    else
      (*s)[id]++;
  }
  for (map<int, int>::iterator it = s->begin(); it != s->end(); ++it) {
    if (it->first == 0) {
      continue;
    }
    if (it->second > 2) {
      cout << -1;
      return 0;
    }
    if (it->second == 2) p++;
  }
  cout << p;
  return 0;
}
