#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int id[n];
  int sum = 0;
  for (int i = 0; i < n; i++) cin >> id[i];
  sort(id, id + n);
  int pairs = 0;
  for (int i = 0; i < n - 1; i++)
    if (id[i] == id[i + 1] && id[i] != 0) pairs++;
  for (int i = 1; i < n - 1; i++)
    if (id[i] == id[i - 1] && id[i] == id[i + 1] && id[i] != 0) pairs = -1;
  cout << pairs << '\n';
  return 0;
}
