#include <bits/stdc++.h>
using namespace std;
map<long long, int> m;
int main() {
  int n;
  scanf("%d", &n);
  long long count = 0;
  int flag = 0;
  for (int i = 0; i < n; i++) {
    long long c;
    cin >> c;
    if (c > 0) {
      m[c] += 1;
      if (m[c] == 2) count++;
      if (m[c] > 2) flag = 1;
    }
  }
  if (flag)
    cout << "-1" << endl;
  else
    cout << count << endl;
  return 0;
}
