M=10**9+7 n=input() x=c=1 for i in range(n): c=c*(n-i)/(i+1) x+=pow(i+1,n-i-1,M)*c print ~-x%M