#include #include #include #include #include #include #include #include #include #define int long long int #define rep(i, n) for(int i = 0; i < (n); ++i) using namespace std; typedef pair P; const int INF = 1e15; const int MOD = 1e9+7; signed main(){ int n; cin >> n; vector a(n); rep(i, n) cin >> a[i]; vector dp(1 << n); dp[0] = 0; rep(s, (1 << n)){ vector x; rep(i, n){ if((s >> i) % 2 == 1){ x.push_back(i); } } if(x.size() % 2 == 1){ continue; } rep(i, (int)x.size()){ for(int j = i+1; j < (int)x.size(); j++){ int ss = s ^ (1 << x[i]) ^ (1 << x[j]); dp[s] = max(dp[s], dp[ss] + (a[x[i]] ^ a[x[j]])); } } } cout << dp[(1 << n) - 1] << endl; return 0; }