#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 rec(int S) { if (S == 0) return 0; int& ret = dp[S]; if (ret != 0) return ret; for (int i = 0; i < n; i++) if (S & 1 << i) { for (int j = i + 1; j < n; j++) { if (S & 1 << j) { int score = A[i] ^ A[j]; int pair = (1 << i) + (1 << j); chmax(ret, rec(S ^ pair) + score); } } } return ret; } int main() { cin >> n; for (int i = 0; i < n; i++) cin >> A[i]; cout << rec((1 << n) - 1) << endl; }