//min25
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#define maxn 500005
#define ll long long
#define mo 1000000007
using namespace std;
ll n,sqr,i,j,k,m,inv6;
ll id1[maxn],id2[maxn],w[maxn];
ll bz[maxn],tot,pri[maxn],sg1[maxn],sg2[maxn];
ll s[maxn],g1[maxn],g2[maxn];
ll ksm(ll x,ll y){
ll s=1;
for(;y;y/=2,x=x*x%mo) if (y&1)
s=s*x%mo;
return s;
}
void getpri(){
for(i=2;i<=sqr;i++){
if (!bz[i]) {
pri[++tot]=i;
sg1[tot]=(sg1[tot-1]+i)%mo;
sg2[tot]=(sg2[tot-1]+1ll*i*i)%mo;
}
for(j=1;j<=tot&&i*pri[j]<=sqr;j++){
bz[i*pri[j]]=1;
if (i%pri[j]==0) break;
}
}
}
void prepare(){
getpri();
for(i=1;i<=n;i=j+1){
j=n/(n/i),w[++m]=n/i;
if (w[m]<=sqr) id1[w[m]]=m; else
id2[n/w[m]]=m;
ll tmp=w[m]%mo;
g1[m]=(tmp+1)*tmp/2%mo-1;
g2[m]=tmp*(tmp+1)%mo*(tmp*2+1)%mo*inv6%mo-1;
}
for(j=1;j<=tot;j++){
for(i=1;i<=m&&pri[j]*pri[j]<=w[i];i++){
int k=(w[i]/pri[j]<=sqr)?id1[w[i]/pri[j]]:id2[n/(w[i]/pri[j])];
(g1[i]-=pri[j]*(g1[k]-sg1[j-1]))%=mo;
(g2[i]-=pri[j]*pri[j]%mo*(g2[k]-sg2[j-1]))%=mo;
}
}
}
ll S(ll x,int j){
if (x==1||pri[j]>x) return 0;
int k=(x<=sqr)?id1[x]:id2[n/x];
ll sum=g2[k]-g1[k]-sg2[j-1]+sg1[j-1];
for(k=j;k<=tot&&pri[k]*pri[k]<=x;k++){
ll p=pri[k],q=p%mo;
while (p*pri[k]<=x){
sum+=S(x/p,k+1)*(q*(q-1)%mo)%mo;
p=p*pri[k],q=q*pri[k]%mo,sum+=q*(q-1)%mo;
}
}
return sum%mo;
}
int main(){
scanf("%lld",&n),sqr=sqrt(n),inv6=ksm(6,mo-2);
prepare();
printf("%lld",S(n,1)+1);
}