#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, i, k, temp, j;
  int a[1003][2];
  int count;
  memset(a, 0, sizeof(a));
  cin >> n;
  k = 0;
  for (i = 0; i < n; i++) {
    cin >> temp;
    for (j = 0; j < k; j++) {
      if (temp == a[j][0]) {
        a[j][1]++;
        break;
      }
    }
    if (j == k) {
      a[k][0] = temp;
      a[k][1] = 1;
      k++;
    }
  }
  count = 0;
  for (i = 0; i < k; i++) {
    if (a[i][1] == 2 && a[i][0] != 0) {
      count++;
    }
    if (a[i][1] >= 3 && a[i][0] != 0) {
      count = -1;
      break;
    }
  }
  cout << count;
}
