#include using namespace std; #include #include using namespace atcoder; //基本的にこれがなくてもうまくいくコードを心がけるが、念の為。時間ギリギリアウトの時は消してみる #define int long long typedef long long ll; typedef unsigned long long ull; typedef double db; typedef long double ldb; typedef pair pi; typedef pair pl; typedef vector vi; typedef vector vl; typedef vector > vvi; typedef vector > vvl; typedef priority_queue pq; typedef priority_queue, greater > pqg; typedef priority_queue pql; typedef priority_queue, greater > pqgl; #define pb push_back #define eb emplace_back #define mp make_pair #define all(obj) (obj).begin(), (obj).end() #define reps(i, n, m) for (int i = (int)(n); i < (int)(m); i++) #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define rrep(i, n) for (int i = n; i >= 0; i--) #define cbit(x) __builtin_popcountll(x) #define minv(v) *min_element(v.begin(), v.end()) #define maxv(v) *max_element(v.begin(), v.end()) #define print(v) \ for (auto k : v) cout << k << " "; \ cout << endl; #define yesno(bool) \ if (bool) { \ cout << "Yes" << endl; \ } else { \ cout << "No" << endl; \ } //既存値aより新規値bが大きければ更新 template bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; } //既存値aより新規値bが小さければ更新 template bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; } #define ednl endl //打ち間違え用 #define enld endl #define Endl endl int dx[4] = {1, 0, -1, 0}; int dy[4] = {0, 1, 0, -1}; // int dx[8] = {1, 1, 1, 0, -1, -1, -1, 0}; // int dy[8] = {-1, 0, 1, 1, 1, 0, -1, -1}; // const int MOD = 998244353; //素数(223*119+1) // const int MOD = 1000000007; //素数 // using mint = modint998244353; // using mint = modint1000000007; // using mint = static_modint<1000000009>; //////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////// signed main() { int n; cin >> n; vi a(n); rep(i, n) { cin >> a[i]; } vl d((1 << n), 0); d[0] = 0; rep(i, 1 << n) { if (cbit(i) % 2 == 1) continue; rep(j, n) { reps(k, j + 1, n) { if ((i & (1 << j)) && (i & (1 << k))) { int l = i & ~(1 << j); l = l & ~(1 << k); d[i] = max(d[i], d[l] + (a[j] ^ a[k])); } } } } cout << d[(1 << n) - 1] << endl; }