#include <bits/stdc++.h>
using namespace std;
long long fact[1000005];
long long ans[1000006];
int main() {
  long long n;
  cin >> n;
  fact[0] = 1;
  for (long long i = 1; i <= n; i++) fact[i] = (fact[i - 1] * i) % 1000000007;
  ans[3] = 2;
  for (long long i = 4; i <= n; i++) {
    ans[i] =
        ((ans[i - 1] * i) % 1000000007 +
         ((fact[i - 1] - ans[i - 1]) * (i - 2)) % 1000000007 + 1000000007) %
        1000000007;
  }
  cout << ans[n] << endl;
}
