#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int a[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  unordered_map<int, int> mp;
  for (int i = 0; i < n; i++) {
    mp[a[i]]++;
  }
  int ans = 0;
  for (auto x : mp) {
    if (x.second == 2 && x.first != 0) {
      ans++;
    } else if (x.second > 2 && x.first != 0) {
      cout << "-1\n";
      return 0;
    }
  }
  cout << ans;
}
