Croc Champ 2013 - Qualification Round
A
Spyke Talks
Codeforces
800
原题
←B →
翻译中…

Polycarpus is the director of a large corporation. There are $*n*$ secretaries working for the corporation, each of them corresponds via the famous Spyke VoIP system during the day. We know that when two people call each other via Spyke, the Spyke network assigns a unique ID to this call, a positive integer session number.

翻译中…

One day Polycarpus wondered which secretaries are talking via the Spyke and which are not. For each secretary, he wrote out either the session number of his call or a 0 if this secretary wasn't talking via Spyke at that moment.

翻译中…

Help Polycarpus analyze these data and find out the number of pairs of secretaries that are talking. If Polycarpus has made a mistake in the data and the described situation could not have taken place, say so.

翻译中…

Note that the secretaries can correspond via Spyke not only with each other, but also with the people from other places. Also, Spyke conferences aren't permitted — that is, one call connects exactly two people.

翻译中…

Input

翻译中…

The first line contains integer $*n*$ $(1 ≤ *n* ≤ 10^{3})$ — the number of secretaries in Polycarpus's corporation. The next line contains $*n*$ space-separated integers: $*id*_{1}, *id*_{2}, ..., *id*_{*n*}$ $(0 ≤ *id*_{*i*} ≤ 10^{9})$. Number $*id*_{*i*}$ equals the number of the call session of the $*i*$-th secretary, if the secretary is talking via Spyke, or zero otherwise.

翻译中…

Consider the secretaries indexed from 1 to $*n*$ in some way.

翻译中…

Output

翻译中…

Print a single integer — the number of pairs of chatting secretaries, or -1 if Polycarpus's got a mistake in his records and the described situation could not have taken place.

翻译中…

Note

翻译中…

In the first test sample there are two Spyke calls between secretaries: secretary 2 and secretary 4, secretary 3 and secretary 5.

翻译中…

In the second test sample the described situation is impossible as conferences aren't allowed.

翻译中…

样例

Input #1
6
0 1 7 1 7 10
Output #1
2
InputCopy OutputCopy
Input #2
3
1 1 1
Output #2
-1
InputCopy OutputCopy
Input #3
1
0
Output #3
0
InputCopy OutputCopy
题目信息
题号
291A
时间限制
2 s
内存限制
256 MB
标签
*special
模拟
排序

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。