#include <bits/stdc++.h>
using namespace std;
void err(istream_iterator<string> it) {}
template <typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {}
struct mycmp {
  bool operator()(const pair<long long, long long>& a,
                  const pair<long long, long long>& b) const {
    return abs(-a.first + a.second + 1) <= abs(-b.first + b.second + 1);
  }
};
long long t, n, k, m, q;
string s;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(20);
  cin >> n;
  map<long long, long long> M;
  for (long long i = (0); i < (n); ++(i)) {
    cin >> q;
    if (q) ++M[q];
  }
  q = 0;
  for (auto it : M)
    if (q != -1)
      if (it.second > 2)
        q = -1;
      else
        q += (it.second == 2);
  cout << q;
  return 0;
}
