#include <bits/stdc++.h>
using namespace std;
vector<int> vec, ves;
int main() {
  int n, m, f = 0, w = 0;
  bool p = false, t = false;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> m;
    if (m == 0) t = true;
    for (int j = 0; j < vec.size(); j++) {
      p = false;
      if (m == vec[j]) {
        ves[j]++;
        p = true;
        break;
      }
    }
    if (p == false) {
      vec.push_back(m);
      ves.push_back(1);
    }
  }
  for (int i = 0; i < vec.size(); i++) {
    if (vec[i] != 0 && ves[i] > 2) {
      cout << -1;
      return 0;
    } else if (ves[i] == 2 && vec[i] != 0)
      w++;
  }
  cout << w;
  return 0;
}
