#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, t;
  scanf("%d", &n);
  set<int> s;
  set<int>::iterator it;
  int flag = 0;
  int ans = 0;
  map<int, int> m;
  while (n--) {
    scanf("%d", &t);
    it = s.find(t);
    if (it == s.end()) {
      s.insert(t);
      m[t] = 1;
    } else {
      m[t]++;
      if (m[t] == 2 && t > 0) {
        ans++;
      }
      if (m[t] == 3 && t > 0) {
        flag = 1;
      }
    }
  }
  if (flag == 0)
    cout << ans << endl;
  else
    cout << "-1" << endl;
  return 0;
}
