#include <bits/stdc++.h>
using namespace std;
map<int, int> id_count;
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    int id;
    cin >> id;
    if (id) {
      if (id_count.find(id) == id_count.end())
        id_count[id] = 1;
      else
        id_count[id]++;
    }
  }
  int ans = 0;
  for (map<int, int>::iterator it = id_count.begin(); it != id_count.end();
       it++) {
    int cnt = it->second;
    assert(cnt >= 1);
    if (cnt > 2) {
      ans = -1;
      break;
    }
    ans += (cnt == 2);
  }
  cout << ans << endl;
}
