#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
int dp[1000006][20][2];
int add(int a, int b) {
  a += b;
  if (a >= MOD) a -= MOD;
  return a;
}
int mul(int a, int b) {
  long long c = ((long long)a * b);
  if (c >= MOD) c %= MOD;
  return (int)c;
}
int f(int n, int j, int k) {
  int num = 1 << j;
  if (k) num *= 3;
  return n / num;
}
int main() {
  int n;
  scanf("%d", &n);
  int two = 0;
  while (1 << two <= n) two++;
  two--;
  int best = 1 << two;
  dp[1][two][0] = 1;
  if (3 * best <= n * 2) dp[1][two - 1][1] = 1;
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j <= two; j++) {
      for (int k = 0; k <= 1; k++) {
        if (!dp[i][j][k]) continue;
        dp[i + 1][j][k] =
            add(dp[i + 1][j][k], mul(dp[i][j][k], max(0, f(n, j, k) - i)));
        if (j)
          dp[i + 1][j - 1][k] =
              add(dp[i + 1][j - 1][k],
                  mul(dp[i][j][k], max(0, f(n, j - 1, k) - f(n, j, k))));
        if (k)
          dp[i + 1][j][k - 1] =
              add(dp[i + 1][j][k - 1],
                  mul(dp[i][j][k], max(0, f(n, j, k - 1) - f(n, j, k))));
      }
    }
  }
  printf("%d\n", dp[n][0][0]);
  return 0;
}
