#define _USE_MATH_DEFINES #include "bits/stdc++.h" using namespace std; #define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i)) #define rep(i,j) FOR(i,0,j) #define each(x,y) for(auto &(x):(y)) #define mp make_pair #define MT make_tuple #define all(x) (x).begin(),(x).end() #define debug(x) cout<<#x<<": "<<(x)< >(b,vector(c,d)) #define vvv(a,b,c,d,e) vector > >(b,vv(a,c,d,e)) using ll = long long; using pii = pair; using vi = vector; using vll = vector; vector sieveFlags(int n) { vector f(n + 1); for (int i = 3; i <= n; i += 2)f[i] = true; for (int i = 3; (long long)i*i <= n; i += 2) { if (f[i])for (int j = i * 3; j <= n; j += i)f[j] = false; } if (n >= 2)f[2] = true; return f; } int main() { ios::sync_with_stdio(false); cin.tie(0); cout << fixed << setprecision(20); int N; cin >> N; auto f = sieveFlags(N); int re = 0; for (int i = 2; i <= N; ++i)if (f[i]) { re += i; } cout << re << endl; }