import numpy as np N = int(input()) def get_sieve_of_eratosthenes(n): if not isinstance(n, int): raise TypeError("n is int-type.") if n < 2: raise ValueError("n is more than 2") data = [i for i in range(2, n + 1)] for d in data: data = [x for x in data if (x == d or x % d != 0)] return data so = get_sieve_of_eratosthenes(N) so = np.array(so) ans = sum(so) d = [] for i in range(N): a = so[i] if a in d: break if a* a> N: break b = a+0 while b *a <=N: b =b*a c = so[so < N//a] try: c = c[-1] except: c =0 if b-a < a*c-a-c: ans += a*c -a-c d.append(c) else: ans += b-a print(ans)