#include #include using namespace std; int main() { int n; cin >> n; int arr[1001]; int ans = 0; for (int i = 0; i <= n; i++) arr[i] = 1; for (int i = 2; i < sqrt(n); i++) if (arr[i]) for (int j = 0; i * (j + 2) <= n; j++) arr[i * (j + 2)] = 0; for (int i = 2; i <= n; i++) if (arr[i]) ans += i; cout << ans << endl; return 0; }