~/algor $ cat problems/kombinatorika-teng-juftliklar
Pairs of equal numbers
Easy
1000 ms
128 MB
33%
An array $a$ of $n$ integers is given. How many pairs $(i; j)$ satisfy $i \lt j$ and $a_{i} = a_{j}$?
Input
The first line contains a positive integer $n$. The second line contains $n$ space-separated positive integers $a_{i}$.
Output
One integer — the number of pairs.
Note
$1 \le n \le 2 * 10^{5}$
$1 \le a_{i} \le 10^{9}$
Examples
Input #1
6 3 1 3 2 3 1
Output #1
4
Input #2
3 1 2 3
Output #2
0