#include <iostream>
#define llint long long
#define mod 1000000007

using namespace std;

llint n;

int main(void)
{
  ios::sync_with_stdio(0);
  cin.tie(0);

	cin >> n;

	llint ans = 0;
	for(int i = 2; i <= min(n, 1000000LL); i++){
		for(llint t = n; t; t /= i) ans += t % i, ans %= mod;
	}

	llint inv2 = (mod+1)/2;

	for(int i = 1; i <= 1000000; i++){
		llint l = n/(i+1)+1, r = n/i;
		l = max(l, 1000001LL);
		if(l > r) continue;
		llint b = n%r, L = (r-l) % mod;
		ans += (L+1) * b % mod, ans %= mod;
		ans += L * (L+1) % mod * inv2 % mod * i % mod, ans %= mod;
		ans += (L+1) * i % mod, ans %= mod;
	}
	cout << ans << endl;

  return 0;
}