#include <bits/stdc++.h>
using namespace std;
map<int, int> mp;
int main() {
  int n;
  cin >> n;
  int t;
  for (int i = 0; i < n; i++) {
    cin >> t;
    mp[t]++;
  }
  int cnt = 0;
  for (map<int, int>::iterator it = mp.begin(); it != mp.end(); it++)
    if (it->second > 2 && it->first != 0) {
      cout << "-1";
      return 0;
    } else if (it->second == 2 && it->first != 0)
      cnt++;
  cout << cnt;
  return 0;
}
