#include <bits/stdc++.h>
using namespace std;
int main(int argc, char *argv[]) {
  int n, a, s = 0, s1 = 0;
  vector<int> id;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a;
    if (a != 0) id.push_back(a);
  }
  for (int i = 0; i < id.size(); i++) {
    for (int j = 0; j < id.size(); j++) {
      if (id[i] == id[j]) s++;
    }
    if (s > 2) {
      cout << -1;
      return 0;
    }
    if (s == 1) s1++;
    s = 0;
  }
  cout << (id.size() - s1) / 2;
  return EXIT_SUCCESS;
}
