#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int x = 0, f = 1;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    x = x * 10 + c - 48;
    c = getchar();
  }
  return x * f;
}
long long f[31][2];
long long fac[11111111], inv[11111111];
int n, M;
long long dfs(int left, int x, int y) {
  long long tmp[31][2];
  for (int i = 0; i <= M; ++i) {
    tmp[i][0] = f[i][0];
    tmp[i][1] = f[i][1];
  }
  long long tot = 0;
  for (int i = x; i <= M; ++i) {
    for (int j = y; j <= 1; ++j) {
      tot += f[i][j];
      f[i][j] = 0;
    }
  }
  if (!x && !y) {
    for (int i = 0; i <= M; ++i) {
      f[i][0] = tmp[i][0];
      f[i][1] = tmp[i][1];
    }
    return fac[tot];
  }
  long long ans = 0;
  if (x) ans += dfs(left - tot, x - 1, y);
  if (y) ans += dfs(left - tot, x, y - 1);
  for (int i = 0; i <= M; ++i) {
    for (int i = 0; i <= M; ++i) {
      f[i][0] = tmp[i][0];
      f[i][1] = tmp[i][1];
    }
  }
  return fac[left - 1] * inv[left - tot] % 1000000007 * tot % 1000000007 * ans %
         1000000007;
}
int main() {
  n = read();
  fac[0] = 1;
  for (int i = 1; i <= n; ++i) fac[i] = fac[i - 1] * i % 1000000007;
  inv[0] = inv[1] = 1;
  for (int i = 2; i <= n; ++i)
    inv[i] = (1000000007 - 1000000007 / i) * inv[1000000007 % i] % 1000000007;
  for (int i = 1; i <= n; ++i) inv[i] = inv[i] * inv[i - 1] % 1000000007;
  f[0][0] = n;
  for (M = 1; f[M - 1][0]; ++M) {
    f[M][0] = f[M - 1][0] >> 1;
  }
  M -= 2;
  for (int i = 0; i <= M; ++i) {
    f[i][0] -= f[i + 1][0];
  }
  f[0][1] = n / 3;
  for (int i = 1; i < M; ++i) {
    f[i][1] = f[i - 1][1] >> 1;
  }
  for (int i = 0; i < M; ++i) {
    f[i][1] -= f[i + 1][1];
  }
  for (int i = 0; i <= M; ++i) {
    f[i][0] -= f[i][1];
  }
  long long ans = dfs(n, M, 0);
  if ((1 << (M - 1)) * 3 <= n) ans += dfs(n, M - 1, 1);
  cout << ans % 1000000007 << endl;
  return 0;
}
