#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  bool bankai = false;
  int *a = new int[n];
  int count = 0;
  bool ay = false;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a, a + n);
  for (int i = 0; i < n; i++) {
    if (a[n - 1] == 0) ay = true;
    if (a[i] == 0)
      count = 0;
    else if (a[i] == a[i + 1] && a[i] == a[i + 2]) {
      cout << -1;
      return 0;
    } else if (a[i] == a[i + 1])
      count++;
  }
  if (ay) {
    cout << 0;
    return 0;
  }
  cout << count;
  return 0;
}
