#include <bits/stdc++.h>
#pragma GCC optimize("-O2")
using namespace std;
void err(istream_iterator<string> it) { cerr << endl; }
template <typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " = " << a << "\t";
  err(++it, args...);
}
template <typename T1, typename T2>
ostream& operator<<(ostream& c, pair<T1, T2>& v) {
  c << "(" << v.first << "," << v.second << ")";
  return c;
}
template <template <class...> class TT, class... T>
ostream& operator<<(ostream& out, TT<T...>& c) {
  out << "{ ";
  for (auto& x : c) out << x << " ";
  out << "}";
  return out;
}
const int LIM = 1e6 + 5, MOD = 1e9 + 7;
int t, n, m, k, x, y, w;
int dp[LIM][20][2];
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  int high = 0;
  for (int i = 19; i >= 0; --i) {
    if ((1 << i) <= n) {
      high = i;
      break;
    }
  }
  dp[1][high][0] = 1;
  bool oth = 0;
  if (high and (1 << (high - 1)) * 3 <= n) oth = 1, dp[1][high - 1][1] = 1;
  for (int i = 1; i < n; ++i) {
    int till = (i ? n / i : (1 << high));
    for (int j = 0; (1 << j) <= till; ++j) {
      dp[i + 1][j][0] += dp[i][j][0] * 1LL * (n / (1 << j) - i) % MOD;
      if (dp[i + 1][j][0] >= MOD) dp[i + 1][j][0] -= MOD;
      if (j) {
        dp[i + 1][j - 1][0] +=
            dp[i][j][0] * 1LL * (n / (1 << (j - 1)) - n / (1 << j)) % MOD;
        if (dp[i + 1][j - 1][0] >= MOD) dp[i + 1][j - 1][0] -= MOD;
      }
    }
    if (oth) {
      for (int j = 0; (1 << j) <= till; ++j) {
        dp[i + 1][j][1] += dp[i][j][1] * 1LL * (n / (3 * (1 << j)) - i) % MOD;
        if (dp[i + 1][j][1] >= MOD) dp[i + 1][j][1] -= MOD;
        if (j) {
          dp[i + 1][j - 1][1] +=
              dp[i][j][1] * 1LL *
              (n / (3 * (1 << (j - 1))) - n / (3 * (1 << j))) % MOD;
          if (dp[i + 1][j - 1][1] >= MOD) dp[i + 1][j - 1][1] -= MOD;
        }
        dp[i + 1][j][0] +=
            dp[i][j][1] * 1LL * (n / (1 << j) - n / (3 * (1 << j))) % MOD;
        if (dp[i + 1][j][0] >= MOD) dp[i + 1][j][0] -= MOD;
      }
    }
  }
  cout << dp[n][0][0] << '\n';
  return 0;
}
