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++14 (GCC 5.4.1) (judge verdict: Wrong Answer)

#include <bits/stdc++.h>
using namespace std;

struct P
{
    int x,y,z;

    bool operator<(const P &a)const{
              return x>a.x;
    }
};


vector<P> v[10];
//bitset<4001000> b;
int a,c,i,b,k,n,d,e,m;//dy[15]={0,1,0,-1,-1,1,-1,1},dx[15]={1,0,-1,0,1,1,-1,-1};//
int l[33];

int o[3000544];
int j[41][6];
int dx[10]={0,1,0,-1,1,1,-1,-1},dy[10]={-1,0,1,0,1,-1,1,-1},dz[10]={0,0,0,0,1,-1};


long long x,y,mod=1000000007;
long long z[1000100],z1[100100];

P u[1000020];
stack<int> s[2];
//queue<int> q,q1,q2;
//set<int> s;
queue<P> q;

//'1'==49;
//'A'==65;
//'a'==97;
//unordered_
//map<long long,long long> p;
//list<int> l;
//string r1,r;
char r[52];
//deque<int> de;
bool as(P a,P b)
{
    if(a.x!=b.x)
    return a.x<b.x;
    return a.y<b.y;
}
long long g(long long a)
{
    if(a<0) return 0;
    return z[a];
}

long long p(long long a,long long b)
{
    if(!b) return 1;
    long long x=p(a,b/2);
    x*=x;
    x%=mod;
    if(b&1) x*=a,x%=mod;
    return x;
}

long long f(long long x,long long y)
{
    if(x<y) return 0;
    //printf("@@%lld %lld\n",z1[y],p(g(y),mod-2));
    return g(x)*p(g(y),mod-2)%mod*p(g(x-y),mod-2)%mod;
}

int main()
{
    scanf("%d",&a);
    if(a==2)
    {
        puts("1");
        return 0;
    }
    z[0]=1;
    z1[0]=1;
    for(int t=1;t<=a;t++)
        z[t]=z[t-1]*t%mod,z1[t]=p(z[t],mod-2);
    long long n=0;
    for(int t=2;t<a;t++)
    {

        y=x;
        x=f(t-1,a-1-t)*g(t)%mod*g(a-1-t)%mod;
        n+=(x-y)*t;
        n%=mod;
        //printf("@@%lld %lld\n",z1[t],p(g(t),mod-2));
        //printf("!!%lld %lld %lld %lld\n",x,f(t-1,a-t-1),g(t),g(a-1-t));
    }
    printf("%lld",n);
}
//128397156