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