#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  while (cin >> n) {
    map<int, int> mp;
    int ans = 0;
    bool fail = false;
    for (int i = 0; i < n; i++) {
      int a;
      cin >> a;
      if (!a) continue;
      if (mp[a] == 2) {
        fail = true;
      }
      mp[a]++;
      if (mp[a] == 2) ans++;
    }
    if (fail)
      puts("-1");
    else
      cout << ans << endl;
  }
}
