#include using namespace std; using LL = long long; using ULL = unsigned long long; #define rep(i,n) for(int i=0; i<(n); i++) template struct static_modint { ULL x; static_modint(ULL val = 0) : x(val) {} static_modint& operator+=(static_modint r) { x += r.x; if (x >= M) x -= M; return *this; } static_modint operator+(static_modint r) const { static_modint res = x; return res += r; } static_modint& operator-=(static_modint r) { x += M - r.x; if (x >= M) x -= M; return *this; } static_modint operator-(static_modint r) const { static_modint res = x; return res -= r; } static_modint& operator*=(static_modint r) { x = x * r.x % M; return *this; } static_modint operator*(static_modint r) const { return static_modint(x * r.x % M); } static_modint pow(ULL r) const { if (r == 0) return static_modint(1); static_modint res = pow(r / 2); res *= res; if (r % 2) res *= *this; return res; } static_modint& operator/=(static_modint r) { *this *= r.pow(M - 2); return *this; } static_modint operator/(static_modint r) const { return *this * (r.pow(M - 2)); } ULL& operator*() { return x; } const ULL& operator*() const { return x; } bool operator==(static_modint r) const { return x == r; } bool operator!=(static_modint r) const { return x != r; } }; static const ULL M = 1000000007; using MLL = static_modint; vector NMul; // number of greater multiples vector RNMul; // number of integers that has just the number of greater multiples ULL F(ULL n) { ULL ans = 0; for (ULL i = 1; i * i <= n; i++) { ULL f = n / i; if (f * f > n) ans += f - 1; } for (ULL i = 1; i * i <= n; i++) ans += (i - 1) * (n / i - n / (i + 1)); ans -= n - 1; return ans; } int main() { ULL N; cin >> N; NMul = { 0 }; RNMul = {}; for (ULL i = 1; i * i <= N; i++) { NMul.push_back(N / i - 1); if (NMul.back() * NMul.back() <= N) NMul.pop_back(); } for (ULL i = 0; i * i <= N; i++) { RNMul.push_back(N / (i + 1) - N / (i + 2)); } MLL ans = MLL(N % M) * MLL((N - 1) % M) * MLL((N - 2) % M); for (ULL i = 1; i < NMul.size(); i++) { MLL tmp = 0; tmp += (NMul[i] * (NMul[i] - 1) % M); tmp += ((N - 2) * (N - 1 - NMul[i]) % M); MLL Fx = F(NMul[i] + 1) % M; tmp += Fx; ans -= tmp; } for (ULL i = 0; i < RNMul.size(); i++) { MLL tmp = 0; tmp += (i * (i - 1) % M); tmp += ((N - 2) * (N - 1 - i) % M); MLL Fx = F(i + 1) % M; tmp += Fx; tmp *= RNMul[i]; ans -= tmp; } cout << *ans << endl; return 0; }