#C4142. Counting Pairs of Flowerbeds

    ID: 47648 Type: Default 1000ms 256MiB

Counting Pairs of Flowerbeds

Counting Pairs of Flowerbeds

You are given n flowerbeds and a list of integers representing the number of flowers in each flowerbed. Your task is to compute the number of distinct pairs of flowerbeds that share the same number of flowers.

For each group of flowerbeds having the same number of flowers, if there are c flowerbeds, the number of pairs is given by the formula: $$\frac{c \times (c - 1)}{2}$$. Sum these values for all groups to obtain the final answer.

Note: The input is read from standard input (stdin) and the output should be written to standard output (stdout).

inputFormat

The input consists of two lines:

  • The first line contains a single integer n \( (1 \le n \le 10^5) \) representing the number of flowerbeds.
  • The second line contains n space-separated integers, where each integer represents the number of flowers in a flowerbed.

outputFormat

Output a single integer which represents the number of distinct pairs of flowerbeds that have the same number of flowers.

## sample
1
1
0

</p>