#include <bits/stdc++.h>
int N, Pairs;
using namespace std;
map<int, int> M;
map<int, int>::iterator it;
int main() {
  cin >> N;
  for (int i = 0; i < N; i++) {
    int id;
    cin >> id;
    if (id == 0) continue;
    it = M.find(id);
    if (it == M.end())
      M.insert(make_pair(id, 1));
    else {
      it->second++;
      if (it->second == 2) Pairs++;
      if (it->second == 3) {
        cout << "-1";
        return 0;
      }
    }
  }
  cout << Pairs;
  return 0;
}
