#include <bits/stdc++.h>
using namespace std;
map<int, int> mp;
int main() {
  ios ::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int n, a[1000 + 5], ans = 0;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i]) mp[a[i]]++;
  }
  for (int i = 0; i < n; i++)
    if (mp[a[i]] > 2) {
      cout << -1;
      return 0;
    } else if (mp[a[i]] == 2)
      ans++;
  cout << ans / 2;
}
