#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, res = 0;
  cin >> n;
  set<int> s1, s2;
  for (int i = 0; i < (int)n; i++) {
    int a;
    cin >> a;
    if (a == 0) continue;
    if (s2.find(a) != s2.end()) {
      cout << -1 << endl;
      return 0;
    }
    if (s1.find(a) != s1.end()) {
      res++;
      s2.insert(a);
    } else
      s1.insert(a);
  }
  cout << res << endl;
}
