Wrong Algorithm

Time limit: 0.5s Memory limit: 256MB Input: Output:

Lorenzo devised an innovative yet incorrect algorithm to count the number of inversions\footnote{An inversion for an array A0,,AN1A_0, \ldots, A_{N - 1} is a pair (i,j)(i, j) such that 0i<jN10 \le i < j \le N - 1 and Ai>AjA_i > A_j.} for any given permutation of NN elements.

Full of optimism, he computed this number for a permutation P0,,PN1P_0, \ldots, P_{N - 1} simply as the sum

12i=0N1Pii.\frac12 \sum_{i = 0}^{N - 1} \left| P_i - i \right|.

Task

Unfortunately his formula has some flaws and the algorithm fails to consistently produce the correct output. Lorenzo is now wondering how often his algorithm yields the wrong answer: help him by counting the number of permutations for which his algorithm fails in computing the number of inversions!

Since the answer might be quite large, you are asked to print it modulo 109+710^9 + 7.

Input data

The input file consists of a line containing integer NN.

Output data

The output file must contain a single line consisting of integer SS.

Constraints and clarifications

  • 1N1061 \leq N \leq 10^6
# Score Constraints
1 0 Examples
2 12 N10N \leq 10
3 28 N100N \leq 100
4 30 N2000N \leq 2000
5 30 No additional restrictions

Example 1

stdin

3

stdout

1

Explanation

In the first sample case, Lorenzo's algorithm computes an incorrect value only for the permutation [2,1,0][2, 1, 0].

Example 2

stdin

4

stdout

10

Log in or sign up to be able to send submissions!