#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  map<int, int> cnt;
  for (int i = 0; i < n; ++i) {
    int id;
    cin >> id;
    if (id == 0) continue;
    ++cnt[id];
  }
  int calls = 0;
  for (auto &call : cnt) {
    if (call.second > 2) {
      cout << -1;
      return 0;
    }
    if (call.second == 2) {
      ++calls;
    }
  }
  cout << calls;
}
