#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define TOSTRING(x) #x #define SZ(x) (int)(x).size() #define REP(i,n) for(int i=0;i<(n);i++) #define FOR(i,a,b) for(int i=(a);i<(b);i++) #define REPR(i,n) for(int i=(n)-1;i>=0;i--) #define ALL(s) (s).begin(), (s).end() #define so(V) sort(ALL(V)) #define rev(V) reverse(ALL(V)) #define uni(v) v.erase( unique(ALL(v)) , v.end()); #define PAU system("pause") typedef long long unsigned int llu; typedef long long ll; typedef vector vi; typedef vector vll; typedef vector vb; typedef vector vvi; typedef vector vvll; typedef vector vvb; const double EPS = 1e-9; const int MOD = 1e9 + 7; const int INF = (1 << 28); const double PI = acos(-1); void eratos(int n, vb &isprime) { isprime = vb(n + 1); REP(i, n + 1) { isprime[i] = true; } isprime[0] = false; isprime[1] = false; for (int i = 2; i * i <= n;i++) { if (isprime[i]) { int j = i + i; while (j <= n) { isprime[j] = false; j += i; } } } } int main() { cin.tie(0); ios::sync_with_stdio(false); vb isPrime; int N; cin >> N; eratos(N,isPrime); int ans = 0; REP(i, N + 1) { if (isPrime[i]) { ans += i; } } cout << ans << endl; PAU; return 0; }