#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int MAX = 1e3 + 10, mod = 998244353;
ll n, k;
ll ans = 0;
ll power(ll x, int y){
ll ans = 1;
while (y){
if (y & 1) ans *= x, ans %= mod;
x *= x, x %= mod;
y >>= 1;
}
return ans;
}
ll safe_sqrt(ll x){
ll lk = 0, rk = 2 * sqrt(x);
while (lk < rk){
ll mid = (lk + rk) >> 1;
if (mid * mid >= x) rk = mid;
else lk = mid + 1;
}
return lk;
}
ll cal(ll x){
ll x1 = (1 + x) * x % mod * power(2,mod - 2) % mod * (n % mod + 1) % mod;
ll x2 = x * (1 + x) % mod * (2 * x % mod + 1) % mod * power(6,mod - 2) % mod;
return (x1 - x2 + mod) % mod;
}
void solve(){
cin >> n;
k = safe_sqrt(n);
for (int i = 2; i <= k; ++ i){
ll t = i - 1;
int cnt = 1;
while (t < n){
ll m = (t + 1) * i - 1;
if (m > n) ans = (ans + i * cnt % mod * (n - t) % mod) % mod;
else ans = (ans + i * cnt % mod * (m - t) % mod) % mod;
t = m;
cnt ++;
}
}
//ans = (ans + (n + 1) * (n + k + 1) % mod * (n - k) / 2) % mod;
ans += mod - cal(k % mod) + cal(n % mod);
cout << ans % mod << endl;
}
signed main(){
ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
//cout << fixed << setprecision(20);
//while (cin >> n)
//int _;cin>>_;while(_--)
solve();
//did();
return 0;
}