N = int(input()) prime = [2,3,5,7,11,13,17,19,23,29,31,37] n = len(prime) ans = 0 dat = list(range(N+1)) dat2 = [0] * (N + 1) for i in range(n): p = prime[i] for j in range(p,N+1,p): while dat[j] % p == 0: dat[j] //= p dat2[j] |= 1 << i for j in range(2,N+1): if dat[j] == j: ans += j dp = [0] * (1 << n) for j in range(2,N+1): dp[dat2[j]] = j for bit in range(1,1 << n): T = bit while T: T -= 1 T &= bit if dp[bit] < dp[T] + dp[bit ^ T]: dp[bit] = dp[T] + dp[bit ^ T] print(ans + max(dp))