#include <bits/stdc++.h>
using namespace std;
int a[1024];
int main() {
  int n;
  while (cin >> n) {
    for (int i = 0; i < n; i++) cin >> a[i];
    sort(a, a + n);
    int p = a[0], cnt = 1;
    bool y = true;
    int sol = 0;
    for (int i = 1; i < n; i++) {
      if (a[i] == 0) continue;
      if (p == a[i])
        cnt++;
      else {
        p = a[i];
        cnt = 1;
      }
      if (cnt > 2)
        y = false;
      else if (cnt == 2)
        sol++;
    }
    if (y) {
      cout << sol << endl;
    } else
      cout << -1 << endl;
  }
  return 0;
}
