1 #include <iostream>
2 #include <vector>
3 #include <algorithm>
4 #include <map>
5
6 using namespace std;
7
8 int main(){
9 int n;
10 cin >> n;
11 map<int,int> id;
12 for(int i = 0; i <n; i ++ ){
13 int a;
14 cin >>a;
15 if(id.find(a) == id.end()) id[a] = 1;
16 else id[a]++;
17 }
18 int cnt = 0 ;
19 bool error = false;
20 for(map<int,int>::iterator it = id.begin(); it!=id.end(); it ++ ){
21 if(it->first == 0) continue;
22 if(it->second > 2){error = true; break;}
23 if(it->second == 2) cnt++;
24 }
25 if(error) cout<<-1<<endl;
26 else if(cnt) cout<<cnt<<endl;
27 else cout<<0<<endl;
28 return 0;
29 }