#include <bits/stdc++.h>
using namespace std;
int main(int argc, char** argv) {
  int n, a, ans = 0;
  map<long, int> mas;
  map<long, int>::iterator it;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> a;
    ++mas[a];
  }
  for (it = mas.begin(); it != mas.end(); ++it)
    if (it->first != 0) {
      if (it->second > 2) {
        cout << -1;
        return 0;
      } else if (it->second == 2)
        ++ans;
    }
  cout << ans;
  return 0;
}
