#include using namespace std; int main() { int N; cin >> N; int A[N]; for (int i = 0; i < N; i++) cin >> A[i]; int DP[(1 << N)] = {}; for (int bits = 0; bits < (1 << N); bits++) { vector matched; for (int i = 0; i < N; i++) { if (bits & (1 << i)) { matched.push_back(i); } } for (size_t i = 0; i < matched.size(); i++) { for (size_t j = i + 1; j < matched.size(); j++) { DP[bits] = max(DP[bits], A[matched[i]] ^ A[matched[j]] + DP[bits ^ (1 << matched[i]) ^ (1 << matched[j])]); } } } cout << DP[(1 << N) - 1] << endl; }