#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, t = 0;
  cin >> n;
  map<int, int> a;
  bool is = true;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    a[x]++;
    if (a[x] == 2 && x != 0) {
      t++;
    }
    if (a[x] == 3 && x != 0) {
      is = false;
    }
  }
  if (is == false) {
    cout << "-1" << endl;
  } else {
    cout << t << endl;
  }
  return 0;
}
