#include <bits/stdc++.h>
using namespace std;
long long v[1001];
int compare(const void* a, const void* b) {
  return (*(long long*)a - *(long long*)b);
}
int main() {
  int n, i, rez = 0, m;
  cin >> n;
  for (i = 0; i < n; i++) cin >> v[i];
  qsort(v, n, sizeof(long long), compare);
  n--;
  m = n - 1;
  for (i = 0; i < n; i++) {
    if (i < m)
      if (v[i] == v[i + 1] && v[i] == v[i + 2] && v[i] != 0) {
        cout << "-1\n";
        return 0;
      }
    if (v[i] == v[i + 1] && v[i] != 0) rez++;
  }
  cout << rez << '\n';
  return 0;
}
