#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
int n, Log, dp[1000005][21][2];
int cnt(int x) { return n / x; }
int main() {
  scanf("%d", &n);
  Log = log2(n);
  dp[1][Log][0] = 1;
  if ((1 << (Log - 1)) * 3 <= n) dp[1][Log - 1][1] = 1;
  for (int i = 2; i <= n; i++) {
    for (int j = 0; j <= Log; j++) {
      dp[i][j][0] =
          (1ll * dp[i - 1][j][0] * (cnt((1 << j)) - (i - 1)) +
           1ll * dp[i - 1][j + 1][0] * (cnt(1 << j) - cnt(1 << (j + 1))) +
           1ll * dp[i - 1][j][1] * (cnt(1 << j) - cnt((1 << j) * 3))) %
          mod;
      dp[i][j][1] = (1ll * dp[i - 1][j][1] * (cnt((1 << j) * 3) - (i - 1)) +
                     1ll * dp[i - 1][j + 1][1] *
                         (cnt((1 << j) * 3) - cnt((1 << (j + 1)) * 3))) %
                    mod;
    }
  }
  printf("%d\n", dp[n][0][0]);
  return 0;
}
