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