#include <bits/stdc++.h>
using namespace std;
using u64 = uint64_t;
long long fact[1000006];
void facto() {
  fact[0] = 1;
  fact[1] = 1;
  for (int i = 2; i < 1000006; i++) fact[i] = (fact[i - 1] * i) % 1000000007;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long t = 1LL;
  facto();
  long long ans[1000006];
  ans[3] = 2;
  for (int i = 4; i < 1000006 - 2; i++)
    ans[i] =
        ((fact[i - 1] * (i - 2)) % 1000000007 + ans[i - 1] * 2) % 1000000007;
  while (t--) {
    long long n;
    cin >> n;
    cout << ans[n];
  }
}
