#include <bits/stdc++.h>
const long long inf = 1e9;
const long long mod = 1e9 + 7;
const long long zero = 0;
const long long maxn = 1e3 + 5;
using namespace std;
map<long long, long long> m;
map<long long, bool> b;
long long n, ans;
long long a[maxn];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    m[a[i]]++;
  }
  for (int i = 0; i < n; i++) {
    if (b[a[i]] == 1 || a[i] == 0) continue;
    b[a[i]] = 1;
    if (m[a[i]] > 2) {
      cout << -1 << endl;
      return 0;
    }
    if (m[a[i]] == 2) ans++;
  }
  cout << ans << endl;
  return 0;
}
