#include using namespace std; using int64 = long long; using uint64 = unsigned long long; const int MAX_N = 14; int64 dp[1 << MAX_N]; int main() { cin.tie(nullptr); ios::sync_with_stdio(false); int N; cin >> N; vector A(N); for (int i = 0; i < N; i++) { cin >> A[i]; } memset(dp, -1, sizeof(dp)); dp[0] = 0; for (int mask = 0; mask < (1 << N); mask++) { for (int i = 0; i < N; i++) { for (int j = 0; j < N; j++) { if (i == j or (mask >> i) & 1 or (mask >> j) & 1) { continue; } int nextMask = mask | (1 << i) | (1 << j); dp[nextMask] = max(dp[nextMask], dp[mask] + (A[i] ^ A[j])); } } } cout << dp[(1 << N) - 1] << endl; return 0; }