#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  map<int, int> s;
  for (int i = 0; i < (n); i++) {
    int a;
    cin >> a;
    s[a]++;
  }
  int ans = 0;
  for (typeof((s).begin()) it = (s).begin(); it != (s).end(); ++it) {
    if (it->first == 0) continue;
    if (it->second == 2) ans++;
    if (it->second > 2) {
      cout << -1 << endl;
      return 0;
    }
  }
  cout << ans << endl;
  return 0;
}
