#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;
const int MOD=10007;
int N;
long long ans=1;
long long qpw(int a,int b)
{
long long re=1;
while(b)
{
if(b&1)
re=(re*a)%MOD;
b=b>>1;
a=(a*a)%MOD;
}
return re;
}
int main()
{
freopen("merge.in","r",stdin);
freopen("merge.out","w",stdout);
scanf("%d",&N);
for(int i=1;i<N;i++)
{
ans*=i;
ans%=MOD;
}
ans*=qpw(N,N-2);
ans%=MOD;
printf("%d\n",ans);
return 0;
}