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 Rust (1.15.1) (judge verdict: Wrong Answer)

// use std::collections::HashMap;


fn invmod(a: i64, p: i64) -> i64 {
    if a == 1 {
        return 1;
    } else {
        return (1 - p*invmod(p%a, a)) / a + p;
    }
}


fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);

    let n: i64 = sc.read();
    let md: i64 = 1_000_000_007;
    // println!("{}", md);

    let mut facn1 = 1;
    for i in 1..n {
        facn1 *= i;
        facn1 %= md;
    }
    let facn1 = facn1;
    // println!("{}", facn1);
    // println!("a");
    let mut ans: i64 = 0;

    let mut x: i64 = facn1;
    ans += x;
    for i in 0..n-2 {
        x *= (n-2 - 2*i);
        x %= md;
        x *= (n-3 - 2*i);
        x %= md;
        let t: i64 = (n-1 - i) * (n-2 - i) * (i + 1);
        x *= invmod(t % md, md);
        x %= md;
        // println!("{}", x);
        ans += (facn1 - x);
        ans %= md;
    }
    ans = (ans + md) % md;


    /*
    let mut x = 1;
    for i in 1..n {
        x *= i;
        x %= md;
        if i * 2 < n {
            ans += facn1;
            ans %= md;
        } else {
        }
    }
    */

    println!("{}", ans);
}

// thanks, ir5
use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;

struct Scanner<'a> {
    cin: StdinLock<'a>,
}

impl<'a> Scanner<'a> {
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner { cin: cin }
    }

    fn read1<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin
            .by_ref()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        token.parse::<T>().ok()
    }

    fn read<T: FromStr>(&mut self) -> T {
        self.read1().unwrap()
    }
}