#P8474. 「GLR-R3」立春

「GLR-R3」立春

Description

Since Tianyi has just woken up and is afraid the statement of the first problem will make everyone confused, this problem only provides a brief description. (Actually, I really cannot make up more story.)

Let σ\sigma be any permutation of length nn, and let τ(σ)\tau(\sigma) denote the number of inversion pairs in it. Compute

σ2τ(σ)\sum_\sigma 2^{\tau(\sigma)}

modulo (109+7)(10^9+7).

Input Format

Input one integer nn in a single line, denoting the length of the permutation.

Output Format

Output one integer in a single line, denoting the required answer.

3
21

Hint

Explanation of the statement

This section introduces the definition of inversion pairs for some contestants. If you are familiar with it, you may skip this section.

For a permutation σ\sigma of length nn, assuming indices start from 11, we say (i,j)(i,j) forms an inversion pair if and only if 1i<jn1\le i<j\le n and σi>σj\sigma_i>\sigma_j. τ(σ)\tau(\sigma) denotes how many different pairs (i,j)(i,j) satisfy the condition above.

For example, for the permutation σ=2,4,1,3\sigma=\lang 2,4,1,3\rang, the inversion pairs are (1,3),(2,3),(2,4)(1,3),(2,3),(2,4), so τ(σ)=3\tau(\sigma)=3. It can be seen that as long as the relative order of the elements in σ\sigma is fixed, τ(σ)\tau(\sigma) is fixed.

Sample #1 Explanation

$$\begin{aligned} \sum_{\sigma}2^{\tau(\sigma)} &= 2^{\tau(\lang 1,2,3\rang)}+2^{\tau(\lang 1,3,2\rang)}+2^{\tau(\lang 2,1,3\rang)}+2^{\tau(\lang 2,3,1\rang)}+2^{\tau(\lang 3,1,2\rang)}+2^{\tau(\lang 3,2,1\rang)}\\ &= 2^0+2^1+2^1+2^2+2^2+2^3\\ &= 21. \end{aligned}$$

Constraints and Notes

This problem uses Subtask-based scoring.

Subtask ID nn Score
11 4\le4 55
22 10\le10 2020
33 100\le100
44 103\le10^3 2525
55 107\le10^7 3030

Translated by ChatGPT 5