#include <bits/stdc++.h>
using namespace std;
long long mod = 1e9 + 7;
int32_t main() {
  vector<long long> powers(1e6 + 10, 1);
  vector<long long> fact(1e6 + 10, 1);
  for (long long i = 2; i <= 1e6 + 2; i++) {
    powers[i] = (2 * powers[i - 1]) % mod;
    fact[i] = (i * fact[i - 1]) % mod;
    if (powers[i] < 0) powers[i] += mod;
    if (fact[i] < 0) fact[i] += mod;
  }
  long long n;
  cin >> n;
  cout << (((fact[n] - powers[n]) % mod) + mod) % mod << endl;
  return 0;
}
