#include<iostream> #include<unordered_map> #define maxn 1000010 #define ll long long usingnamespacestd;
constint p = 998244353;
int pri[maxn], mu[maxn], cnt; bool isp[maxn]; voidinit_isp(int n){ mu[1] = 1; for (int i = 2; i <= n; ++i) { if (!isp[i]) pri[++cnt] = i, mu[i] = -1; for (int j = 1; j <= cnt && i * pri[j] <= n; ++j) { isp[i * pri[j]] = 1; if (i % pri[j] == 0) break; mu[i * pri[j]] = -mu[i]; } } for (int i = 1; i <= n; ++i) mu[i] += mu[i - 1]; }
unordered_map<int, int> _mu; constint N = 1000000; intcalc_mu(int n){ if (n <= N) return mu[n]; if (_mu.find(n) != _mu.end()) return _mu[n]; int ans = 1; for (ll l = 2, r; l <= n; l = r + 1) { r = n / (n / l); ans -= (r - l + 1) * calc_mu(n / l); } return _mu[n] = ans; }
cin >> n; init_isp(N); ll ans = 0; for (int l = 1, r; l <= n; l = r + 1) { r = n / (n / l); ll v = n / l; ans = (ans + (calc_mu(r) - calc_mu(l - 1)) * v % p * v % p * v) % p; } cout << (ans + p) % p << "\n"; return0; }