#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  set<int> s1;
  set<int> s2;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    if (x == 0) continue;
    if (!(binary_search(s1.begin(), s1.end(), x)))
      s1.insert(x);
    else if (!(binary_search(s2.begin(), s2.end(), x)))
      s2.insert(x);
    else {
      cout << -1 << endl;
      return 0;
    }
  }
  cout << s2.size() << endl;
  return 0;
}
