#include <bits/stdc++.h>
using namespace std;
int n;
int id[1111];
int main() {
  scanf("%d", &n);
  for (int i = (0); i < (n); ++i) scanf("%d", id + i);
  int ans = 0;
  for (int i = (0); i < (n); ++i) {
    if (id[i] != 0) {
      int cnt = 0;
      for (int j = (0); j < (n); ++j)
        if (i != j && id[j] == id[i]) cnt++;
      if (cnt > 1) {
        printf("-1");
        return 0;
      } else if (cnt == 1)
        ans++;
    }
  }
  printf("%d\n", ans / 2);
  return 0;
}
