#include <bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[]) {
  int n, x;
  while (cin >> n) {
    map<int, int> a;
    for (int i = 0; i < n; i++) {
      cin >> x;
      if (x != 0) a[x]++;
    }
    int ans = 0, ans1 = 0, ans2 = 0;
    for (map<int, int>::iterator it = a.begin(); it != a.end(); it++) {
      if (it->second == 2)
        ans++;
      else if (it->second < 2)
        ans1++;
      else
        ans2++;
    }
    if (ans2 == 0 && ans > 0)
      cout << ans << endl;
    else if (ans2 == 0 && ans == 0)
      cout << 0 << endl;
    else
      cout << -1 << endl;
  }
  return 0;
}
