#include <bits/stdc++.h>
using namespace std;
map<int, int> m;
map<int, int>::iterator ite;
void solve() {
  int n, i, dem, x;
  dem = 0;
  bool si = true;
  m.clear();
  scanf("%d", &n);
  for (i = 1; i <= n; i++) {
    scanf("%d", &x), m[x]++;
    if (m[x] > 2 && x > 0) {
      si = false;
    }
  }
  if (si == false) {
    cout << -1 << endl;
    return;
  }
  for (ite = m.begin(); ite != m.end(); ite++) {
    if (ite->second == 2 && ite->first > 0) dem++;
  }
  cout << dem << endl;
  ;
}
int main() {
  solve();
  return 0;
}
