# 推式子

1、a*b*d<=n
2、(a,b)=1
a和b定了，d的取值就有nab$\frac{n}{ab}$
ans=na=1nb=1[(a,b)=1]nab$ans=\sum_{a=1}^n\sum_{b=1}^n[(a,b)=1]*\frac{n}{ab}$

f[k]=na=1nb=1[(a,b)=k]nab$f[k]=\sum_{a=1}^n\sum_{b=1}^n[(a,b)=k]*\frac{n}{ab}$
g[k]=nki=1f[ki]$g[k]=\sum_{i=1}^{\frac{n}{k}}f[k*i]$

f[k]=ni=1μ(i)g[ki]$f[k]=\sum_{i=1}^n\mu(i)*g[k*i]$
g是很容易算的，所以
f[k]=ni=1μ(i)nkia=1nkib=1(nk2)ab$f[k]=\sum_{i=1}^n\mu(i)*\sum_{a'=1}^{\frac{n}{k*i}}\sum_{b'=1}^{\frac{n}{k*i}}\frac{(\frac{n}{k^2})}{a'b'}$

ans=nd=1μ(d)nd2a=1nd2b=1(nd2)ab$ans=\sum_{d=1}^n\mu(d)*\sum_{a'=1}^{\frac{n}{d^2}}\sum_{b'=1}^{\frac{n}{d^2}}\frac{(\frac{n}{d^2})}{a'b'}$

ans=nd=1μ(d)nd2a=1nd2b=1(nd2)ab$ans=\sum_{d=1}^{\sqrt n}\mu(d)*\sum_{a'=1}^{\frac{n}{d^2}}\sum_{b'=1}^{\frac{n}{d^2}}\frac{(\frac{n}{d^2})}{a'b'}$

# 算f

f(x)=xi=1xj=1xij$f(x)=\sum_{i=1}^x\sum_{j=1}^x\frac{x}{ij}$

# 算g

g(x)=xi=1xi$g(x)=\sum_{i=1}^x\frac{x}{i}$

g(x)=xi=1d(i)$g(x)=\sum_{i=1}^xd(i)$
d函数表示约数个数。

dalao说，以n2/3$n^{2/3}$为界，记为N。我们需要筛出g(1~N)，然后对于x<=N便直接得解。

#include<cstdio>
#include<algorithm>
#include<cmath>
#define fo(i,a,b) for(i=a;i<=b;i++)
using namespace std;
typedef long long ll;
const int N=3000000,mo=1000000007;
int mu[N+10],sum[N+10],mem[N+10],d[N+10],pri[N+10];
bool bz[N+10];
int i,j,k,l,t,m,top,ans;
ll n;
void prepare(){
int i,j;
mu[1]=1;
fo(i,2,N){
if (!bz[i]){
pri[++top]=i;
mu[i]=-1;
}
fo(j,1,top){
if ((ll)i*pri[j]>N) break;
bz[i*pri[j]]=1;
if (i%pri[j]==0){
mu[i*pri[j]]=0;
break;
}
mu[i*pri[j]]=-mu[i];
}
}
fo(i,1,N)
fo(j,1,N/i)
d[i*j]++;
fo(i,1,N) sum[i]=sum[i-1]+d[i],mem[i]=-1;
}
int calcg(ll x){
if (x<=N) return sum[x];
if (mem[n/x]>=0) return mem[n/x];
ll i=1,j;
int t=0;
while (i<=x){
j=x/(x/i);
(t+=(ll)(j-i+1)*(x/i)%mo)%=mo;
i=j+1;
}
return mem[n/x]=t;
}
int calcf(ll x){
ll i=1,j;
int t=0;
while (i<=x){
j=x/(x/i);
(t+=(ll)calcg(x/i)*(j-i+1)%mo)%=mo;
i=j+1;
}
return t;
}
int main(){
freopen("ra.in","r",stdin);freopen("ra.out","w",stdout);
prepare();
scanf("%lld",&n);
fo(i,1,floor(sqrt(n)))
if (mu[i]) (ans+=mu[i]*calcf(n/i/i))%=mo;
ans=((ll)(n%mo)*(n%mo)%mo-ans)%mo;
(ans+=mo)%=mo;
printf("%d\n",ans);
}