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