Problem:
Score : 800 points

Problem Statement

There are N squares lining up in a row, numbered 1 through N from left to right.
Initially, all squares are white.
We also have N-1 painting machines, numbered 1 through N-1.
When operated, Machine i paints Square i and i+1 black.

Snuke will operate these machines one by one.
The order in which he operates them is represented by a permutation of (1, 2, ..., N-1), P, which means that the i-th operated machine is Machine P_i.

Here, the score of a permutation P is defined as the number of machines that are operated before all the squares are painted black for the first time, when the machines are operated in the order specified by P.
Snuke has not decided what permutation P to use, but he is interested in the scores of possible permutations.
Find the sum of the scores over all possible permutations for him.
Since this can be extremely large, compute the sum modulo 10^9+7.

Constraints

2 \leq N \leq 10^6

Input

Input is given from Standard Input in the following format:

N

Output

Print the sum of the scores over all possible permutations, modulo 10^9+7.

Sample Input 1

4

Sample Output 1

16

There are six possible permutations as P.
Among them, P = (1, 3, 2) and P = (3, 1, 2) have a score of 2, and the others have a score of 3.
Thus, the answer is 2 \times 2 + 3 \times 4 = 16.

Sample Input 2

2

Sample Output 2

1

There is only one possible permutation: P = (1), which has a score of 1.

Sample Input 3

5

Sample Output 3

84

Sample Input 4

100000

Sample Output 4

341429644

Solution in C# (Mono 4.6.2.0) (judge verdict: Accepted)

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AGC023C {
    class Program {
        static void Main(string[] args) {
            int N = int.Parse(Console.ReadLine());
            long[] fact = new long[N];
            long[] invfact = new long[N];
            fact[0] = 1;
            invfact[0] = 1;
            for (int i = 1; i < N; i++) {
                fact[i] = multiply(fact[i - 1], i);
                invfact[i] = divide(1, fact[i]);
            }
            long[] nums = new long[N];
            for (int i = 1; i < N; i++) {
                long conbi = 0;
                if (i - 1 >= N - 1 - i) {
                    conbi = multiply(fact[i - 1], multiply(invfact[N - 1 - i], invfact[(i - 1) - (N - 1 - i)]));
                }
                nums[i] = multiply(multiply(fact[i], fact[N - 1 - i]), conbi);
            }
            long ans = 0;
            for (int i = 1; i < N; i++) {
                ans = (ans + multiply((nums[i] - nums[i - 1] + mod), i)) % mod;
            }
            Console.WriteLine(ans);
        }

        //定数です
        const long mod = 1000000007;

        //mod下でのx×yです
        private static long multiply(long x, long y) {
            return (x % mod) * (y % mod) % mod;
        }

        //mod下でのxのy乗です
        private static long power(long x, long y) {
            if (y == 0) {
                return 1;
            } else if (y == 1) {
                return x % mod;
            } else if (y % 2 == 0) {
                long p = power(x, y / 2);
                return p * p % mod;
            } else {
                long p = power(x, y / 2);
                return (p * p) % mod * (x % mod) % mod;
            }
        }

        private static long divide(long x, long y) {
            return multiply(x, power(y, mod - 2));
        }
    }
}