#include <bits/stdc++.h>
using namespace std;
void gnomeSort(int arr[], int n) {
  int index = 0;
  while (index < n) {
    if (index == 0) index++;
    if (arr[index] >= arr[index - 1])
      index++;
    else {
      int temp = arr[index];
      arr[index] = arr[index - 1];
      arr[index - 1] = temp;
      index--;
    }
  }
  return;
}
int main() {
  int numberOfSecretary;
  int numberOfPair = 0;
  int numberOfInCall = 0;
  cin >> numberOfSecretary;
  int arr[numberOfSecretary];
  for (int i = 0; i < numberOfSecretary; i++) {
    cin >> arr[i];
  }
  gnomeSort(arr, numberOfSecretary);
  for (int i = 0; i < numberOfSecretary; i++) {
    numberOfPair = 0;
    int temp;
    if (arr[i] > 0) {
      temp = arr[i];
    }
    for (int j = i; j < numberOfSecretary; j++) {
      if (arr[j] == temp) {
        numberOfPair++;
      }
    }
    if (numberOfPair > 0) {
      if (numberOfPair == 2) {
        numberOfInCall = numberOfInCall + (numberOfPair / 2);
      } else if ((numberOfPair % 2 == 0 || numberOfPair % 2 == 1) &&
                 numberOfPair > 2) {
        numberOfInCall = -1;
        break;
      }
    } else if (numberOfPair == 1) {
      numberOfInCall = numberOfInCall;
    }
  }
  cout << numberOfInCall;
  return 0;
}
