题目描述
Problem Description
Given a positive integer $N$, Natsubi-kun prepares an empty sequence $Q$ and then freely chooses a permutation of the sequence $P = (P_1, P_2, \dots, P_N)$ from $(1, 2, \dots, N)$. He performs the following series of operations $N$ times:
- Let $x$ be the first element of $P$, and add $x$ to the front or the end of $Q$.
- Remove $x$ from $P$.
Natsubi-kun performs these operations in such a way that the inversion number of the final $Q$ is minimized.
There are $N!$ possible permutations of $P$, and for each of them, you need to find the minimum inversion number of $Q$ after the operations, and then output the sum of these minimum inversion numbers modulo $998244353$.
What is an inversion number? For a permutation of $(1, 2, \dots, N)$, $P' = (P'_1, P'_2, \dots, P'_N)$, the inversion number is the number of pairs of integers $i, j$ such that $1 \leq i < j \leq N$ and $P'_i > P'_j$.
Input Format
The input is given from the standard input in the following format:
$N$
Output Format
Output the answer in one line.
Sample Input and Output
Sample Input #1
4
Sample Output #1
20
Sample Input #2
220328
Sample Output #2
192799865
Notes/Hints
Constraints
- $1 \leq N \leq 3 \times 10^5$
- All inputs are integers.
Sample Explanation 1
For example, when $P = (3, 2, 1, 4)$, by performing the operations appropriately, $Q$ can be made into $(1, 2, 3, 4)$, which has an inversion number of $0$. Calculating similarly for other $P$, the answer is found to be $20$.
Sample Explanation 2
Original problem by NatsubiSogan
输入格式
见题面 Input 部分
输出格式
见题面 Output 部分