#include <bits/stdc++.h>
using namespace std;
const long long int MOD = 1000000007;
long long int N, M, K, H, W, L, R;
long long int power(long long int x, long long int n, long long int M) {
  long long int tmp = 1;
  if (n > 0) {
    tmp = power(x, n / 2, M);
    if (n % 2 == 0)
      tmp = (tmp * tmp) % M;
    else
      tmp = (((tmp * tmp) % M) * x) % M;
  }
  return tmp;
}
list<int> Prime(int num) {
  list<int> P;
  for (int i = 5; i <= num; i += 6) {
    bool flag = true;
    for (auto j : P) {
      if (j * j > i) {
        break;
      }
      if (i % j == 0) {
        flag = false;
        break;
      }
    }
    if (flag) P.push_back(i);
    flag = true;
    for (auto j : P) {
      if (j * j > i + 2) {
        break;
      }
      if ((i + 2) % j == 0) {
        flag = false;
        break;
      }
    }
    if (flag) P.push_back(i + 2);
  }
  P.push_front(3);
  P.push_front(2);
  return P;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> N;
  auto P = Prime(sqrt(N) + 1);
  vector<vector<int>> p_box(N + 1);
  for (int i = 2; i <= N; i++) {
    int box = i;
    vector<int> v;
    for (auto j : P) {
      while (box % j == 0) {
        if (v.empty() || v.back() != j) v.push_back(j);
        box /= j;
      }
    }
    if (box > 1) {
      v.push_back(box);
    }
    for (int j = 0; j < (1 << v.size()); j++) {
      int add = 1;
      int cnt = 0;
      for (int k = 0; k < v.size(); k++) {
        if ((j >> k) & 1) {
          add *= v[k];
          cnt++;
        }
      }
      if (cnt & 1)
        p_box[i].push_back(-add);
      else
        p_box[i].push_back(add);
    }
  }
  vector<vector<int>> edge(N + 1);
  for (int i = 1; i <= N; i++) {
    for (int j = i; j <= N; j += i) {
      edge[j].push_back(i);
    }
  }
  vector<long long int> rev_by(N + 1);
  for (int i = 1; i <= N; i++) {
    rev_by[i] = power(i, MOD - 2, MOD);
  }
  vector<long long int> dp(N + 1, rev_by[N]);
  vector<long long int> p(N + 1, rev_by[N]);
  for (int i = N; i >= 1; i--) {
    dp[i] *= power(p[i], MOD - 2, MOD);
    dp[i] %= MOD;
    int mo = N - N / i;
    long long int add = N * rev_by[mo] + dp[i];
    add %= MOD;
    add *= p[i];
    add %= MOD;
    for (int j = 0; j < edge[i].size() - 1; j++) {
      int fig = 0;
      int box = i / edge[i][j];
      for (auto k : p_box[box]) {
        if (k > 0) {
          fig += N / (k * edge[i][j]);
        } else {
          fig -= N / (-k * edge[i][j]);
        }
      }
      long long int aadd = add * fig;
      aadd %= MOD;
      aadd *= rev_by[mo];
      aadd %= MOD;
      dp[edge[i][j]] += aadd;
      dp[edge[i][j]] %= MOD;
      aadd = fig * p[i];
      aadd %= MOD;
      aadd *= rev_by[mo];
      aadd %= MOD;
      p[edge[i][j]] += aadd;
      p[edge[i][j]] %= MOD;
    }
  }
  for (int i = 1; i <= N; i++) {
  }
  cout << dp[1] << endl;
  return 0;
}
