#include using namespace std; int n; int gcd(int a, int b) { if (b == 0) return a; return gcd(b, a % b); } int main() { int i, j, k; int ans = -1; cin >> n; for (i = 0; i < (1LL << (n - 1)); i++) { bool usedNum[41] = {false}; for (j = 0; j < n - 1; j++) { if ((i >> j) % 2 == 1) { usedNum[j+2] = true; } } bool flag = true; for (j = 2; j <= n; j++) { if (!usedNum[j]) continue; for (k = 2; k <= n; k++) { if (!usedNum[k] || j == k) continue; if (gcd(j, k) >= 2) { flag = false; } } } if (flag) { int score = 0; for (j = 2; j <= n; j++) { if (usedNum[j]) { score += j; } } ans = max(ans, score); } } cout << ans << endl; return 0; }