#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  while (scanf("%d", &n) > 0) {
    map<int, int> ids;
    bool test = true;
    int pairs = 0;
    while (n--) {
      int id;
      scanf("%d", &id);
      if (id == 0) continue;
      ids[id]++;
      if (ids[id] > 2) test = false;
      if (ids[id] == 2) pairs++;
    }
    printf("%d\n", test ? pairs : -1);
  }
}
