#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-9;
const int inf = 1e9 + 23;
const int size = 1000 * 2;
int a[size];
int main(void) {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  sort(a, a + n);
  a[n] = a[n + 1] = -1;
  int i = 0, ans = 0;
  while (a[i] == 0) i++;
  while (i < n) {
    if (a[i] == a[i + 2]) {
      cout << "-1" << endl;
      return 0;
    }
    if (a[i] == a[i + 1]) ans++;
    i++;
  }
  cout << ans << endl;
  return 0;
}
