#include using namespace std; typedef long long ll; void shave(vector &v, int n) { vector x, y; int n_sq = sqrt(n) + 1; for (int i = 3; i < n + 1; i += 2) { x.push_back(i); } for (int i = 3; i < n_sq; i += 2) { for (auto itr = x.begin(); itr != x.end(); itr++) { if (*itr == i || *itr % i != 0) y.push_back(*itr); } x.clear(); x = y; y.clear(); } if (n >= 2) x.insert(x.begin(), 2); for (auto itr = x.begin(); itr != x.end(); itr++) { v.push_back(*itr); } } int main(){ int n, ans; cin >> n; vector primes; shave(primes, n); for (int x : primes) ans += x; cout << ans << endl; return 0; }