#ifndef ONLINE_JUDGE #define _GLIBCXX_DEBUG #endif #include using namespace std; // #include // using namespace atcoder; using ll = long long; // 2^63-1まで 負の値は可 using ull = unsigned long long; // 0<= ull <=2^64-1の範囲 負の値は不可 using lll = __int128_t; // 1e38まで 計算に使う場合はなるべく型を合わせる using vl = vector; using vs = vector; using vvl = vector; using P = pair; using G = vector; template using MNPQ = priority_queue, greater>; template using MXPQ = priority_queue, less>; #define rep(i, n) for (ll i = 0; i < n; i++) #define srep(i, s, n) for (int i = s; i < n; i++) #define rrep(i, s, n) for (ll i = s; i > n; i--) #define nall(a) a.begin(), a.end() #define rall(a) a.rbegin(), a.rend() #define chmax(x, y) x = max(x, y) #define chmin(x, y) x = min(x, y) #define lwb(a, x) (ll)(lower_bound(nall(a), x) - a.begin()) #define upb(a, x) (ll)(upper_bound(nall(a), x) - a.begin()) #define vunique(v) v.erase(unique(nall(v)), v.end()) #define pb push_back #define YN(flg) cout << (flg ? "Yes" : "No") << endl #define debug(x) cerr << #x << " = " << x << endl; const ll INF = 2e18; template void vprint(vector& a) { for (auto& x : a) cout << x << ' '; cout << endl; } template void vvprint(vector>& a) { for (auto& row : a) vprint(row); } template void mapprint(map& a) { for (auto ite = a.begin(); ite != a.end(); ite++) { cout << "{key:" << ite->first << ", item:" << a[ite->first] << "} "; } cout << endl; } bool out_grid(ll x, ll y, ll h, ll w) { return !(0 <= x && x < h && 0 <= y && y < w); } // デバッグ用 void print128(lll x) { string res = ""; while (x > 0) { res += '0' + x % 10; x /= 10; } reverse(nall(res)); cout << res << endl; } int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); ll n; cin >> n; vl a(n); rep(i, n) cin >> a[i]; vector arr(1 << n); vector b; rep(i, n) srep(j, i + 1, n) { arr[(1 << i) + (1 << j)] = a[i] ^ a[j]; b.push_back((1 << i) + (1 << j)); } vector> dp(b.size() + 1, vector(1 << n)); rep(i, b.size()) { rep(j, 1 << n) { dp[i + 1][j] = dp[i][j]; if ((j & b[i]) == b[i]) chmax(dp[i + 1][j], dp[i][j & ~b[i]] + arr[b[i]]); } } cout << dp.back().back() << endl; return 0; }