#define _CRT_SECURE_NO_WARNINGS #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define Ma_PI 3.141592653589793 #define eps 0.00000000000000000000000001 #define LONG_INF 10000000000000000LL #define GOLD 1.61803398874989484820458 #define MAX_MOD 1000000007 #define MOD 998244353 #define REP(i,n) for(long long i = 0;i < n;++i) long long inv(long long now) { long long ans = 1; long long te = MAX_MOD - 2LL; while (te != 0) { if (te % 2 == 1) { ans *= now; ans %= MAX_MOD; } te /= 2; now *= now; now %= MAX_MOD; } return ans; } int used[4000000] = {}; long long solve(long long n) { long long now_ans = 0; vector gogo[2]; gogo[0].push_back(1); gogo[1].push_back(1); long long now_bot = 2; long long now_top = n; used[1] = 2; for (int i = 0;; ++i) { if (i % 2 == 0) { gogo[0].push_back(now_top); used[now_top]++; if (used[now_top] == 2) break; now_top--; gogo[1].push_back(now_top); used[now_top]++; if (used[now_top] == 2) break; now_top--; } else { gogo[0].push_back(now_bot); used[now_bot]++; if (used[now_bot] == 2) break; now_bot++; gogo[1].push_back(now_bot); used[now_bot]++; if (used[now_bot] == 2) break; now_bot++; } } if (n % 2 == 0) { gogo[1].pop_back(); now_ans += gogo[1][gogo[1].size() - 1] * gogo[0][gogo[0].size() - 1]; } for (int i = 0; i < gogo[0].size() - 1; ++i) { now_ans += gogo[0][i] * gogo[0][i + 1]; } REP(i, gogo[1].size() - 1) { now_ans += gogo[1][i] * gogo[1][i + 1]; } return now_ans; } int main(){ long long n; cin >> n; cout << solve(n) << endl; return 0; vector gogo; for (int i = 1; i <= n; ++i) { gogo.push_back(i); } long long ans = LONG_INF; vector> now_te; do { if (gogo[0] != 1) break; long long now_ans = 0; for (int i = 0; i < gogo.size() - 1; ++i) { now_ans += gogo[i] * gogo[i + 1]; } now_ans += gogo[0] * gogo[gogo.size() - 1]; if (now_ans == ans) { now_te.push_back(gogo); } else if (now_ans < ans) { ans = now_ans; now_te.clear(); now_te.push_back(gogo); } } while (next_permutation(gogo.begin(), gogo.end())); cout << ans << endl; REP(i, now_te.size()) { REP(q, now_te[i].size()) { cout << now_te[i][q] << " "; } cout << endl; } return 0; }