#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define nl '\n'
#define mod 1000000007
#define fori(i,n) for(ll i=0;i < n;i++)
#define forn(i,n) for(ll i=1;i <= n;i++)
#define forx(i,x,n) for(ll i=x;i < n;i++)
#define sortx(x) sort(x.begin(),x.end())
#define sorty(x) sort(x.begin(),x.end(),greater<>())
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
using namespace __gnu_pbds;
#define ordered_multiset tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update>

ll Mod(ll base, ll exp, ll MOD){
    if(exp == 0) return 1;
    ll res = Mod(base,exp/2,MOD);
    if(exp % 2) 
      return (((res * res) % MOD)*base) % MOD;
    else
      return (res*res) % MOD;
}

ll gcd(ll x,ll y){
  ll b = min(x,y);
  ll a = max(x,y);
  while(b != 0){
    ll temp = b;
    b = a % b;
    a = temp;
  }
  return a;
}

ll div(vector<ll> &x){
  for(ll i=1;i <= 1000007;i++){
    for(ll j=i;j <= 1000007;j+=i){
      x[j]++;
    }
  }
}

bool prime(ll n){
  int c=0;
  for(ll i=1;i <= n;i++){
    if(n % i == 0) c++;
    if(c > 2) break;
  }
  if(c == 2) return true;
  return false;
}*/

void generatePrimes(int limit, vector<bool> &isPrime) {
    isPrime.assign(limit + 1, true); 
    isPrime[0] = isPrime[1] = false; 

    for (int i = 2; i * i <= limit; i++) {
        if (isPrime[i]) {
            for (int j = i * i; j <= limit; j += i) {
                isPrime[j] = false;
            }
        }
    }
}

ll computePrimeSums(ll n, ll &sum, const vector<bool> &isPrime) {
    for (int i = 2; i <= n; i++) {
        sum += (isPrime[i] ? i : 0);
    }
    return sum;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    const int LIMIT = 100000;
    vector<bool> isPrime(LIMIT + 1, true);
    ll sum=0;
    generatePrimes(LIMIT, isPrime);
    ll n;
    cin >> n;
    computePrimeSums(n, sum, isPrime);
    cout << sum << nl;
    return 0;
}
