#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1000 * 2;
int x[MAXN];
int ans = 0;
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> x[i];
  sort(x + 1, x + n + 1);
  int cnt = 0;
  for (int i = 1; i <= n; i++) {
    if (x[i] != 0) {
      if (x[i] != x[i - 1]) {
        cnt = 1;
      } else {
        cnt++;
        if (cnt > 2) {
          cout << -1 << endl;
          return 0;
        }
        ans++;
      }
    }
  }
  cout << ans << endl;
  return 0;
}
