#include<cstdio>
#include<cmath>
#include<cstring>
#include<map>
#include<algorithm>
#define maxn 5000000
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define two 500000004
#define six 166666668
using namespace std;
inline long long getint()
{
long long num=0,flag=1;char c;
while((c=getchar())<'0'||c>'9')if(c=='-')flag=-1;
while(c>='0'&&c<='9')num=num*10+c-48,c=getchar();
return num*flag;
}
long long n;
bool not_prime[maxn+5];
int prime[maxn+5],cnt;
long long phi[maxn+5];
map<long long,long long>M;
inline void init()
{
phi[1]=1;
for(int i=2;i<=maxn;i++)
{
if(!not_prime[i])prime[++cnt]=i,phi[i]=i-1;
for(int j=1;j<=cnt&&i*prime[j]<=maxn;j++)
{
not_prime[i*prime[j]]=1;
if(i%prime[j])phi[i*prime[j]]=phi[i]*phi[prime[j]];
else{phi[i*prime[j]]=phi[i]*prime[j];break;}
}
}
for(int i=1;i<=maxn;i++)(phi[i]*=1ll*i*i%MOD)%=MOD;
for(int i=1;i<=maxn;i++)(phi[i]+=phi[i-1])%=MOD;
}
inline long long getsqr(long long x)
{return x%MOD*((x+1)%MOD)%MOD*((2*x+1)%MOD)%MOD*six%MOD;}
inline long long solve(long long x)
{
if(x<=maxn)return phi[x];
if(M.count(x))return M[x];
long long sum=x%MOD*((x+1)%MOD)%MOD*two%MOD;
(sum*=sum)%=MOD;
for(long long i=2,j;i<=x;i=j+1)
{
j=x/(x/i);
(sum-=(getsqr(j)-getsqr(i-1))%MOD*solve(x/i)%MOD)%=MOD;
(sum+=MOD)%=MOD;
}
return M[x]=sum;
}
int main()
{
init();
n=getint();
long long sum=0;
for(long long i=1,j;i<=n;i=j+1)
{
j=n/(n/i);
(sum+=1ll*(j+i)%MOD*(j-i+1)%MOD*two%MOD*solve(n/i)%MOD)%=MOD;
}
printf("%lld
",sum);
}