Equal pairs - MarisaOJ: Marisa Online Judge

Equal pairs

Time limit: 1000 ms
Memory limit: 256 MB
You are given an array integer $A$ of length $n$. Find the number of pairs $(i, j)$ that $A_i = A_j$ and $i \neq j$. ### Input - The first line contains an integer $n$. - The second line contains $n$ integers $A_i$. ### Output - One integer is the number of pairs you found. ### Constraints - $1 \le n \le 10^5$. - $1 \le A_i \le 10^5 $. ### Example Input: ``` 5 1 2 2 1 1 ``` Output: ``` 4 ```