about summary refs log tree commit diff
path: root/2ndary/10/CSP-KT2/negpairs.c
blob: 577fdf86238c5cb0a7ba1a961412c9439dc78d54 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include <stdio.h>

int main()
{
	long n, i;
	long unsigned_a[201] = {};
	long *a = &unsigned_a[100];
	char a0;
	long long v;

	scanf("%ld", &n);
	for (i = 0; i < n; i++) {
		scanf("%hhd", &a0);
		a[a0]++;
	}

	v = a[0] * (a[0] - 1) / 2;
	for (i = 1; i <= 100; i++)
		v += a[i] * a[-i];

	printf("%lld\n", v);

	return 0;
}