#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 20;
const int mod = 1e9 + 7;
long long fact[N], tavan[N], dp[N];
int main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  long long n;
  cin >> n;
  fact[0] = 1;
  dp[3] = 2;
  for (int i = 1; i <= n; i++)
    fact[i] = (((fact[i - 1] * i) % mod) + mod) % mod;
  for (int i = 4; i <= n; i++) {
    dp[i] = ((((dp[i - 1] * 2) + (i - 2) * fact[i - 1]) % mod) + mod) % mod;
  }
  cout << dp[n];
}
