#include #include #include #include #include #include #include #include #include #include #include #include #include #include #define rep(i,a,b) for(int i=a;i=b;i--) #define fore(i,a) for(auto &i:a) #define all(x) (x).begin(),(x).end() typedef long long ll; using namespace std; const int inf = INT_MAX / 2; const ll infl = 1LL << 62; const double PI = 2 * acos(0.0); templatebool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; } templatebool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; } ll gcd(ll a, ll b) { return a ? gcd(b % a, a) : b; } int n; int A[20]; int dp[20000]; int main() { cin >> n; for (int i = 0; i < n; i++) cin >> A[i]; for (int msk = 0; msk < 1 << n; msk++) { for (int a = 0; a < n; a++) for (int b = a + 1; b < n; b++) { if (!(msk & 1 << a) && !(msk & 1 << b)) { chmax(dp[msk + (1 << a) + (1 << b)], dp[msk] + (A[a] ^ A[b])); } } } cout << dp[(1 << n) - 1] << endl; }