https://cses.fi/paste/6a1435305a277a1a97b09b/
#include <bits/stdc++.h> using namespace std; #define int unsigned long long int G(int n) { return n*(n+1)/2; } signed main() { int n; cin >> n; int res = 0, MOD = 1e9 + 7, t = (int)sqrt(n); for(int i = 1; i <= t ; i++) { res += G((n/i)%MOD)%MOD; res += (i * (n/i))%MOD; res %= MOD; } res += MOD - (G(t)*t)%MOD; res %= MOD; cout << res; }