#include <bits/stdc++.h>
int sec[1009];
int main() {
  int n, i, j, sum, ans = 0, no;
  scanf("%d", &n);
  for (i = 0; i < n; i++) scanf("%d", &sec[i]);
  for (i = 0; i < n; i++) {
    sum = 0;
    if (sec[i] <= 0) continue;
    no = sec[i];
    for (j = 0; j < n; j++)
      if (no == sec[j]) {
        sum++;
        sec[j] = -5;
      }
    if (sum != 1 && sum != 2) {
      printf("-1\n");
      return 0;
    }
    if (sum == 2) ans++;
  }
  printf("%d\n", ans);
  return 0;
}
