#K67032. Counting Repeated Version Numbers

    ID: 32552 Type: Default 1000ms 256MiB

Counting Repeated Version Numbers

Counting Repeated Version Numbers

You are given a commit history of a file represented by version numbers. Your task is to count the total number of extra occurrences for any version number that appears more than once. In other words, if a version number appears (k) times, it contributes (k-1) to the count. Compute the sum of these contributions for all version numbers.

inputFormat

The input consists of two lines. The first line contains an integer (n), which denotes the total number of commits. The second line contains (n) space-separated integers representing the version numbers after each commit.

outputFormat

Output a single integer: the total number of extra occurrences of version numbers, calculated as (\sum (k-1)) for each version that appears (k) times where (k > 1).## sample

4
4 3 2 1
0