#include #include #include typedef long long int int64; #define MAX(a,b) ((a)>(b)?(a):(b)) #define MIN(a,b) ((a)<(b)?(a):(b)) #define ABS(a) ((a)>(0)?(a):-(a)) int modPow(int r,int n,int mod){ int t=1; int s=r; while(n>0){ if(n&0x01) t=(int64)t*s%mod; s=(int64)s*s%mod; n>>=1; } return t; } void run(void){ int n; scanf("%d",&n); const int mod=1000000007; int way=0; int comb=n; int r; for(r=1;r<=n;r++){ way=(way+(int64)comb*modPow(r,n-r,mod))%mod; comb=(int64)comb*(n-r)%mod*modPow(r+1,mod-2,mod)%mod; } printf("%d\n",way); } int main(void){ run(); return 0; }