// verification-helper: PROBLEM https://yukicoder.me/problems/7107 #include using namespace std; #define call_from_test template struct Mint{ inline static constexpr T mod = MOD; T v; Mint():v(0){} Mint(signed v):v(v){} Mint(long long t){v=t%MOD;if(v<0) v+=MOD;} Mint pow(long long k){ Mint res(1),tmp(v); while(k){ if(k&1) res*=tmp; tmp*=tmp; k>>=1; } return res; } static Mint add_identity(){return Mint(0);} static Mint mul_identity(){return Mint(1);} Mint inv(){return pow(MOD-2);} Mint& operator+=(Mint a){v+=a.v;if(v>=MOD)v-=MOD;return *this;} Mint& operator-=(Mint a){v+=MOD-a.v;if(v>=MOD)v-=MOD;return *this;} Mint& operator*=(Mint a){v=1LL*v*a.v%MOD;return *this;} Mint& operator/=(Mint a){return (*this)*=a.inv();} Mint operator+(Mint a) const{return Mint(v)+=a;} Mint operator-(Mint a) const{return Mint(v)-=a;} Mint operator*(Mint a) const{return Mint(v)*=a;} Mint operator/(Mint a) const{return Mint(v)/=a;} Mint operator+() const{return *this;} Mint operator-() const{return v?Mint(MOD-v):Mint(v);} bool operator==(const Mint a)const{return v==a.v;} bool operator!=(const Mint a)const{return v!=a.v;} static Mint comb(long long n,int k){ Mint num(1),dom(1); for(int i=0;i ostream& operator<<(ostream &os,Mint m){os< void inc(vector &as,F f){ assert(as[0]==T(0)); int n=as.size(); vector sieve(n,false); for(int p=2;p void dec(vector &as,F f){ assert(as[0]==T(0)); int n=as.size(); vector sieve(n,false); for(int p=2;p void zeta(vector &as){ auto f=[](T &lo,T &hi){lo+=hi;}; DivisorTransform::dec(as,f); } template void moebius(vector &as){ auto f=[](T &lo,T &hi){lo-=hi;}; DivisorTransform::inc(as,f); } } namespace LCMConvolution{ template void zeta(vector &as){ auto f=[](T &lo,T &hi){hi+=lo;}; DivisorTransform::inc(as,f); } template void moebius(vector &as){ auto f=[](T &lo,T &hi){hi-=lo;}; DivisorTransform::dec(as,f); } } #undef call_from_test const int MAX = 2e5+10; int pr[MAX]={}; int sq[MAX]={}; int sign[MAX]={}; signed main(){ cin.tie(0); ios::sync_with_stdio(0); for(int i=2;i>n; sign[1]=1; for(int i=2;i<=n;i++){ if(sq[i]) continue; sign[i]=-sign[i/pr[i]]; } using M = Mint; vector way(n+1,0),emp(n+1,0); M all{0}; M cnt{0}; for(int i=1;i<=n;i++){ way[i]=M(sign[i])*M(2).pow(n/i); emp[i]=M(sign[i])*M(1).pow(n/i); all+=way[i]; cnt+=emp[i]; } LCMConvolution::zeta(way); LCMConvolution::zeta(emp); vector dp0(n+1,0),dp1(n+1,0),dp2(n+1,0); for(int i=1;i<=n;i++){ dp0[i]=emp[i]*emp[i]; dp1[i]=emp[i]*way[i]; dp2[i]=way[i]*way[i]; } LCMConvolution::moebius(dp0); LCMConvolution::moebius(dp1); LCMConvolution::moebius(dp2); M ans=(all-cnt)*(all-cnt); M cof=M(3)/M(4); for(int i=1;i<=n;i++){ ans+=dp2[i]*cof.pow(n/i); ans-=M(2)*dp1[i]; ans+=dp0[i]; ans-=dp2[i]; ans+=M(2)*dp1[i]; ans-=dp0[i]; } cout<