#include #include #include #include #include #include #include using namespace std; using ll = long long; vector prime_vector(int n) { int m = (int)sqrt(n - 1); vector q(n); for (int i = 2; i <= m; i++) { if (q[i]) continue; for (int j = i * i; j < n; j += i) { q[j] = true; } } vector p; p.reserve(n / log(n * 0.329)); for (int i = 2; i < n; i++) { if (!q[i]) p.push_back(i); } return p; } int main() { int n; cin >> n; auto pv = prime_vector(max(n, 10) + 1); int r = 0; for (auto& p : pv) { if (p > n) break; r += p; } cout << r << endl; return 0; }