#include #include #include #include #define REP(i, a, b) for (int i = int(a); i < int(b); i++) #define dump(val) cerr << __LINE__ << ":\t" << #val << " = " << (val) << endl using namespace std; typedef long long int lli; template vector make_v(size_t a, T b) { return vector(a, b); } template auto make_v(size_t a, Ts... ts) { return vector(a, make_v(ts...)); } int main() { int N; cin >> N; vector isPrime(N + 1, true); vector Prime; isPrime[0] = isPrime[1] = false; REP(i, 2, N + 1) { if (isPrime[i]) { Prime.push_back(i); for (int j = 2 * i; j < N + 1; j += i) { isPrime[j] = false; } } } const int PSZ = Prime.size(); vector memo(PSZ, 0); REP(i, 2, N + 1) { vector plst; REP(j, 0, PSZ) { if (i % Prime[j] == 0 && memo[j] != 0) { plst.push_back(memo[j]); } } sort(begin(plst), end(plst)); plst.erase(unique(begin(plst), end(plst)), end(plst)); int cnt = 0; for (int &n : plst) { cnt += n; } if (i > cnt) { REP(j, 0, PSZ) { if (i % Prime[j] == 0) { memo[j] = i; } } } } sort(begin(memo), end(memo)); memo.erase(unique(begin(memo), end(memo)), end(memo)); int ans = 0; for (int &n : memo) { ans += n; } cout << ans << endl; return 0; }