#include #include #include #include #include #include #include #include #include #include #include #define rep(i,a,b) for(int i=a;i=b;i--) #define fore(i,a) for(auto &i:a) #define all(x) (x).begin(),(x).end() using namespace std; vector Eratosthenes(int n) { vector a(n, 1); rep(i, 2, sqrt(n)) { if (a[i]) { for (int j = 0; i*(j + 2)< n; j++) { a[i*(j + 2)] = 0; } } } vector primes; for (int i = 2; i < n; i++) { if (a[i]) { primes.push_back(i); } } return primes; } int main() { int n; cin >> n; auto ans = Eratosthenes(n+1); int sum = 0; fore(i, ans) { sum += i; } cout << sum << endl; return 0; }