import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); boolean[] isNotPrimes = new boolean[n + 1]; isNotPrimes[0] = true; isNotPrimes[1] = true; for (int i = 2; i <= n; i++) { if (!isNotPrimes[i]) { for (int j = 2; i * j <= n; j++) { isNotPrimes[i * j] = true; } } } long sum = 0; for (int i = 2; i <= n; i++) { if (!isNotPrimes[i]) { sum += i; } } System.out.println(sum); } }