#include #define rep(i,a,b) for(int i=a;i=b;i--) #define fore(i,a) for(auto &i:a) #define all(x) (x).begin(),(x).end() #pragma GCC optimize ("-O3") using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); } typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60; templatebool chmax(T &a, const T &b) { if (abool chmin(T &a, const T &b) { if (b makePrimes(int n) { // [2,n] vector res, primes(n + 1, 1); primes[0] = primes[1] = 0; rep(i, 2, sqrt(n)) if (primes[i]) for (int j = 0; i * (j + 2) <= n; j++) primes[i * (j + 2)] = 0; rep(i, 2, n + 1) if (primes[i]) res.push_back(i); return res; } /*---------------------------------------------------------------------------------------------------             ∧_∧       ∧_∧  (´<_` )  Welcome to My Coding Space!      ( ´_ゝ`) /  ⌒i     /   \    | |     /   / ̄ ̄ ̄ ̄/  |   __(__ニつ/  _/ .| .|____      \/____/ (u ⊃ ---------------------------------------------------------------------------------------------------*/ int N; int dp[206][1<<11]; int f[1 << 11]; //--------------------------------------------------------------------------------------------------- void _main() { cin >> N; auto allpr = makePrimes(N); auto halfpr = makePrimes(sqrt(N) + 1); int n = allpr.size(); int m = halfpr.size(); rep(i, m, n) rep(msk, 0, 1 << m) { for (int j = 1; j * allpr[i] <= N; j++) { int num = j * allpr[i]; int ms = 0; rep(k, 0, m) if (num % halfpr[k] == 0) ms += 1 << k; if ((msk & ms) == 0) chmax(dp[i + 1][msk + ms], dp[i][msk] + num); } } rep(i, 2, N + 1) { int ms = 0; int ok = 1; rep(j, 0, n) { if (i % allpr[j] == 0) { if (j < m) ms += 1 << j; else ok = 0; } } if (ok) chmax(f[ms], i); } rep(msk, 0, 1 << m) for (int msk2 = msk; msk2 >= 0; msk2--) { msk2 &= msk; chmax(f[msk], f[msk2] + f[msk - msk2]); } int ans = 0; rep(msk, 0, 1 << m) chmax(ans, dp[n][msk] + f[(1 << m) - 1 - msk]); cout << ans << endl; }