#include <bits/stdc++.h>
using namespace std;
int i, j, k, l, m, n, x, y, z, ans, counting;
int ara[2000];
int main() {
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> ara[i];
  }
  sort(ara, ara + n);
  for (i = 0; i < n; i++) {
    if (ara[i] != 0) break;
  }
  for (j = i + 1, counting = 1; j < n; j++) {
    if (ara[j] == ara[j - 1]) {
      counting++;
    } else {
      counting = 1;
    }
    if (counting > 2) {
      printf("-1");
      return 0;
    } else if (counting == 2)
      ans++;
  }
  cout << ans;
  return 0;
}
