#include <bits/stdc++.h>
using namespace std;
const int inf = int(1e9);
const double eps = 1e-9;
const double pi = 4 * atan(double(1));
map<int, int> mem;
int main() {
  int n;
  scanf("%d", &n);
  int ans = 0;
  for (int i = 0; i < n; i++) {
    int cur;
    scanf("%d", &cur);
    if (cur == 0) {
      continue;
    }
    mem[cur]++;
    if (mem[cur] > 2) {
      printf("-1\n");
      return 0;
    }
    if (mem[cur] == 2) {
      ans++;
    }
  }
  printf("%d\n", ans);
  return 0;
}
