#include <bits/stdc++.h>
using namespace std;
const int inf = (int)1e9;
const double eps = 1e-9;
map<int, int> m;
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; (i) < (n); ++i) {
    int x;
    scanf("%d", &x);
    if (x == 0) continue;
    if (m.find(x) != m.end())
      m[x] += 1;
    else
      m[x] = 1;
  }
  int res = 0;
  for (typeof((m).begin()) it = m.begin(); it != (m).end(); ++it) {
    int cc = (*it).second;
    if (cc == 2) res += 1;
    if (cc > 2) {
      printf("-1\n");
      return 0;
    }
  }
  printf("%d\n", res);
  return 0;
}
