ull M=1000000007,D=1<<27,x=0,A=0,
T[]={1,638916270,864357307,711403642,373979365,963971145,183143523,894672548};
{
	char c; while(c=getchar(),'0'<=c&&c<='9'&&x<=M) x=x*10+c-'0';
	x=min(x-1,M);
	A=T[x/D];
	rep(i,x++/D*D+1,x) A=M-A*i%M;
	wt(A%M);
}