#include #include #include #include #include #include #include #include #include #include #include #define MAX_N 100001 #define INF_INT 2147483647 #define INF_LL 9223372036854775807 #define REP(i,n) for(int i=0;i<(int)(n);i++) void init(int n); int find(int n); void unite(int x,int y); bool same(int x, int y); int dx[4] = {1,0,0,-1}; int dy[4] = {0,1,-1,0}; using namespace std; typedef long long int ll; typedef pair P; bool cmp_P(const P &a,const P &b){ return a.second < b.second; } int N,A[15],DP[16384]; vector sets(0); int solve(int code){ if(DP[code] != -1) return DP[code]; int m = -1,back=code; if(code == 0) return 0; else{ for(int i=0;i> i)&1){ code = code ^ (1 << i); for(int j=i+1;j> j) & 1){ code = code ^ (1 << j); m = max(m,(sets[i]^sets[j]) + solve(code)); code = code ^ (1 << j); } } } code = back; } } return DP[back] = m; } int main() { int A; cin >> N; REP(i,N){ cin >> A; sets.push_back(A); } REP(i,(1 << 14) - 1) DP[i] = -1; sort(sets.begin(),sets.end()); cout << solve((1 << N)-1) << endl; return 0; }