#include <bits/stdc++.h>
using namespace std;
long long n, m, k, x, y, z;
long long b[300500], c[300500];
long long a[300500];
long long Abs(long long x) { return (x > 0 ? x : -x); }
vector<long long> g[25];
long long fac[1005000], invfac[1000500];
long long binpow(long long x, long long y) {
  if (y == 0) {
    return 1;
  }
  long long tmp = binpow(x, y / 2);
  tmp = tmp * tmp % 1000000007;
  if (y % 2) {
    return x * tmp % 1000000007;
  }
  return tmp;
}
long long prod(long long l, long long r) {
  if (l > r) {
    return 1;
  }
  return fac[r] * invfac[l - 1] % 1000000007;
}
int main() {
  fac[0] = invfac[0] = 1;
  for (int i = 1; i <= 1000001; i++) {
    fac[i] = fac[i - 1] * i % 1000000007;
    invfac[i] = binpow(fac[i], 1000000007 - 2);
  }
  cin >> n;
  long long x = 1;
  while (x * 2 <= n) {
    x *= 2;
    k++;
  }
  long long px = x;
  while (px > 1) {
    g[0].push_back(px);
    px /= 2;
  }
  g[0].push_back(1);
  long long sz = 1;
  if (x / 2 * 3 <= n) {
    for (int i = 1; i <= k; i++) {
      long long xx = x / 2 * 3;
      g[i].push_back(xx);
      for (int j = 1; j <= k; j++) {
        if (i == j) {
          xx /= 3;
        } else {
          xx /= 2;
        }
        g[i].push_back(xx);
      }
    }
    sz = k + 1;
  }
  long long ans = 0;
  for (int i = 0; i < sz; i++) {
    long long used = 0;
    long long tmp = 1;
    for (auto x : g[i]) {
      long long k = n / x - used;
      tmp = tmp * prod(n - used - k + 1, n - used - 1) % 1000000007 * k %
            1000000007;
      used += k;
    }
    ans += tmp;
  }
  cout << ans % 1000000007 << endl;
  return 0;
}
