#P5972. [PA 2019] Desant

[PA 2019] Desant

Description

Given a permutation a1..na_{1..n} of 11 to nn, it has 2n12^n - 1 non-empty subsequences.

For each kk, find a subsequence of length kk such that the number of inversions in this subsequence is minimal, and output the number of subsequences whose inversion count is minimal.

Input Format

The first line contains a positive integer nn.

The second line contains nn positive integers a1,a2,...,ana_1, a_2, ..., a_n.

Output Format

Output nn lines, each containing two integers. On the kk-th line, output the minimum number of inversions among subsequences of length kk, and the number of subsequences that achieve this minimum.

5
5 3 1 4 2
0 5
0 3
1 2
3 1
7 1

Hint

For 100%100\% of the testdata, 1kn1 \le k \le n, 1n401 \le n \le 40, 1ain,aiaj1 \le a_i \le n, a_i \ne a_j.

Translated by ChatGPT 5