#K11826. Counting Stable Pairs

    ID: 23555 Type: Default 1000ms 256MiB

Counting Stable Pairs

Counting Stable Pairs

You are given a permutation of power levels of n elements. The task is to count the number of stable pairs among these elements. A stable pair is defined as any pair of distinct indices (i, j) with i < j. Mathematically, the number of such pairs is given by the formula: $$\frac{n(n-1)}{2}$$. Although the power levels are provided, they do not affect the outcome, as only the number of elements matters.

Read the input, compute the number of stable pairs, and output the result.

inputFormat

The input consists of two lines. The first line contains a single integer n representing the number of power levels. The second line contains n space-separated integers representing the power levels. Note that the actual values do not affect the result, as the answer is always computed as $$\frac{n(n-1)}{2}$$.

outputFormat

Output a single integer which is the number of stable pairs.## sample

4
1 2 3 4
6

</p>