#include #include #include #include #include //--------------------------- using namespace std; //--------------------------- #define REP(i,n) for(int i = 0; i < (n); i++) #define P(x) cout << (x) << "\n" //--------------------------- int main(){ int n;cin >> n; long long m = 1e9+7; long long ans; if (n == 1) { ans =1; }else{ vector v(n+1); v[0]=0; v[1]=1; for (int i = 2; i < n+1; i++) { v[i] = (i * v[i-1] + v[i-2]) %m; } ans = (v[n] - v[n-2]+m)%m;} cout << ans << "\n"; return 0; }