Skip to main content
Tuesday (24.11.2026) at 20:00: ALGOR Contest: Round #4 (Special Challenge) starts!

~/algor $ cat problems/kombinatorika-teng-juftliklar

Pairs of equal numbers

Easy 1000 ms 128 MB 33%
Share

An array $a$ of $n$ integers is given. How many pairs $(i; j)$ satisfy $i \lt j$ and $a_{i} = a_{j}$?

Array elements; elements with equal values are joined in pairs by arcs

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

Sign in to submit a solution

Signing up is free and takes a minute.