#include <bits/stdc++.h>#pragma GCC optimize(3 , "Ofast","inline")usingnamespace std;
typedef longlong ll ;constint INF =0x3f3f3f3f, N =1e5 +10;constint mod =998244353;voidread(ll &x){
x =0;char c =getchar();while(!isdigit(c)) c =getchar();while(isdigit(c)) x = x *10+ c -48, c =getchar();}
ll qmi(ll a , ll b){
ll res =1;while(b){if(b &1) res = res * a % mod ;
a = a * a % mod ;
b >>=1;}return res ;}
ll get(ll x){
x %= mod ;return x % mod *(x +1)% mod *(2* x +1)% mod *qmi(6, mod -2)% mod ;}intmain(){
ll n ;read(n);
ll ans =0;for(ll i =2; i <= n ;i ++){
ll res =1;if(i * i > n){
ll q = n % mod ;
n %= mod ;
ans =(ans +(n +1)% mod *(n + i)% mod *(n - i % mod +1+ mod)% mod *qmi(2, mod -2)% mod )% mod;// ans = (ans + (n + 1) % mod * (i + n) % mod * (n - i % mod + 1 + mod) % mod * qmi(2 , mod - 2) % mod ) % mod;
ans =(ans -(get(n)-get(i -1)+10ll * mod)% mod +10ll * mod)% mod ;break;}else{for(ll l = i , temp =0;l <= n ;l = res , temp ++){
res *= i ;if(res > n){
ans =(ans + i % mod * temp % mod *(n % mod - l +1+ mod)% mod)% mod ;break;}else{
ans =(ans + i % mod * temp % mod *(res % mod - l + mod)% mod)% mod ;}}}}
cout << ans << endl ;return0;}