#include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long ll; int main() { int N; cin >> N; int A[N]; for (int i = 0; i < N; ++i) { cin >> A[i]; } int dp[1 << N]; memset(dp, 0, sizeof(dp)); for (int i = 0; i < N / 2; ++i) { for (int mask = 0; mask < (1 << N); ++mask) { if (__builtin_popcount(mask) != 2 * i) continue; for (int s = 0; s < N; ++s) { if (mask >> s & 1) continue; for (int t = 0; t < N; ++t) { if (mask >> t & 1) continue; int nmask = mask | (1 << s) | (1 << t); dp[nmask] = max(dp[nmask], dp[mask] + (A[s] ^ A[t])); } } } } cout << dp[(1 << N) - 1] << endl; return 0; }