#include<iostream> #include<vector> #define maxn 5010 #define ll long long #define INF 1000000000 usingnamespacestd;
constint p = 1000000007;
ll pow_mod(ll x, ll n){ ll s = 1; for (; n; n >>= 1, x = x * x % p) if (n & 1) s = s * x % p; return s; }
int pri[maxn], num[maxn], cnt; voiddecomposition(int n){ for (int p = 2; p * p <= n; ++p) { if (n % p) continue ; pri[++cnt] = p; num[cnt] = 0; while (n % p == 0) ++num[cnt], n /= p; } if (n > 1) pri[++cnt] = n, num[cnt] = 1; }
int n;
ll ans; voiddfs(int o, int d, int phi){ if (o == cnt + 1) return ans = (ans + pow_mod(n, n / d - 1) * phi) % p, void(); for (int i = 0; i <= num[o]; ++i) { dfs(o + 1, d, phi); d *= pri[o]; if (!i) phi *= pri[o] - 1; else phi *= pri[o]; } }
voidwork(){ cin >> n; ans = cnt = 0; decomposition(n); dfs(1, 1, 1); cout << ans << "\n"; }