#include <bits/stdc++.h>
using namespace std;
const long long N = 1e6 + 5;
const long long mod = 1e9 + 7;
long long power(long long x, long long y) {
  long long res = 1;
  while (y) {
    if (y & 1) res = res * x % mod;
    x = x * x % mod;
    y >>= 1;
  }
  return res;
}
long long fac[N];
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  fac[0] = 1;
  for (long long i = 1; i < N; i++) fac[i] = i * fac[i - 1] % mod;
  long long T = 1;
  while (T--) {
    long long n;
    cin >> n;
    long long ans = (fac[n] - power(2, n - 1) + mod) % mod;
    cout << ans << '\n';
  }
  return 0;
}
