#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  scanf("%d", &n);
  map<int, int> cnt;
  for (int i = 0; i < n; i++) {
    int a;
    scanf("%d", &a);
    cnt[a]++;
  }
  int res = 0;
  for (map<int, int>::iterator i = cnt.begin(); i != cnt.end(); i++) {
    if (i->first != 0) {
      if (i->second > 2) {
        printf("-1");
        return 0;
      }
      if (i->second == 2) {
        res++;
      }
    }
  }
  printf("%d", res);
  return 0;
}
