#include <iostream>
using namespace std;
int main() {
long long n, m = 1e9 + 7;
cin >> n;
long long res;
if(n == 1){
res=0;
}else{
res = (1 * (n % 2 == 0) + -1 * (n % 2 == 1));
long long prev = res;
for (long long i = n - 1; i >1; i--) {
res += prev * (-i - 1 +m) % m;
prev *= (-i - 1);
prev = (prev + m) % m;
res = (res + m) % m;
}
}
cout << res;
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPiAKdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCmludCBtYWluKCkgewogICAgCiAgICBsb25nIGxvbmcgbiwgbSA9IDFlOSArIDc7CiAgICBjaW4gPj4gbjsKICAgIGxvbmcgbG9uZyByZXM7CiAgICBpZihuID09IDEpewogICAgCXJlcz0wOwogICAgCQogICAgfWVsc2V7CiAgICAJcmVzID0gKDEgKiAobiAlIDIgPT0gMCkgKyAtMSAqIChuICUgMiA9PSAxKSk7CgkgICAgbG9uZyBsb25nIHByZXYgPSByZXM7CgkgICAgZm9yIChsb25nIGxvbmcgaSA9IG4gLSAxOyBpID4xOyBpLS0pIHsKCSAgICAgICAgcmVzICs9IHByZXYgKiAoLWkgLSAxICttKSAlIG07CgkgICAgICAgIHByZXYgKj0gKC1pIC0gMSk7CgkgICAgICAgIHByZXYgPSAocHJldiArIG0pICUgbTsKCSAgICAgICAgcmVzID0gKHJlcyArIG0pICUgbTsKCSAgIH0KICAgIH0KICAgIGNvdXQgPDwgcmVzOwogICAgcmV0dXJuIDA7CgkKfQ==