JAVA 代码
import java.util.Scanner;
public class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int[] arr = new int[1010];
for(int i = 0;i<n;i++){
int t = sc.nextInt();
arr[Math.abs(t)]++;
}
int res = 0;
for(int i =0;i<arr.length;i++)
{
if(arr[i] == 2){
res++;
}
}
System.out.println(res);
}
}