#include <bits/stdc++.h>
using namespace std;
long long a[1005];
int main() {
  int n;
  while (~scanf("%d", &n)) {
    for (int i = 0; i < n; i++) {
      scanf("%I64d", &a[i]);
    }
    sort(a, a + n);
    int count1 = 0;
    int flag = 0;
    for (int i = 0; i < n; i++) {
      if (a[i] == 0)
        continue;
      else if (a[i] == a[i + 1] && a[i + 1] != a[i + 2]) {
        count1++;
      } else if (a[i] == a[i + 1] && a[i + 1] == a[i + 2]) {
        flag = 2;
        break;
      }
    }
    if (flag)
      printf("-1\n");
    else
      printf("%d\n", count1);
  }
  return 0;
}
