#include <bits/stdc++.h>
int s, i, j, c[101], cmax, n, x, y, k;
void sol() {
  std ::vector<int> v;
  s = 0;
  for (i = 0; i < n; i++) {
    scanf("%d", &k);
    v.push_back(k);
  }
  sort(v.begin(), v.end());
  i = 0;
  while (v[i] == 0 & i < n - 1) {
    i++;
  }
  while (i < n - 1) {
    if (v[i] == v[i + 1]) {
      if (v[i + 1] == v[i + 2]) {
        printf("-1\n");
        return;
      } else {
        i += 2;
        s++;
      }
    } else {
      i++;
    }
  }
  printf("%d\n", s);
  return;
}
int main() {
#pragma comment(linker, "/STACK:16777216")
  while (scanf("%d", &n) != EOF) {
    sol();
  }
  return 0;
}
