import std.stdio, std.string, std.conv; import std.algorithm, std.math; import std.range; import std.container.rbtree, std.container.dlist; import std.container.binaryheap, std.container.array; import std.typecons; alias mstring = char[]; const long INF = 1L << 60L; const long mod = 1_000_000_000 + 7; void chmin(T)(ref T x, T y) { x = min(x, y); } void chmax(T)(ref T x, T y) { x = max(x, y); } // 単一の数値を取得 // readln.chomp.to!int; // or // int a; // readf("%s\n", a); // 複数の数値を取得(可変数個の場合推奨) // readln.chomp.split.map!(to!long).array // 複数の数値を取得(固定数個の場合、推奨) // int a, b; // readf("%s %s\n", &a, &b); // インデントを一個ずらして複数の数値を取得(累積和とかで1-indexedの方が良い時がある) // long[] vs = readln.chomp.split.map!(to!long).array; // vs = [0L] ~ vs; // 小数点は以下で指定 // double ret = 10.0; // writefln("%.12f", ret); // 配列の最後の要素は arr[$-1] でアクセスできる void main() { int N = readln.chomp.to!int; auto as = readln.chomp.split.map!(to!long).array; as = [0L] ~ as; auto cst = new long[][](N + 1, N + 1); foreach (i; 1 .. N + 1) foreach (j; 1 .. N + 1) cst[i][j] = as[i] ^ as[j]; auto dp = new long[](1 << N); foreach (s; 0 .. (1 << N)) foreach (i; 1 .. N + 1) { if (s & (1 << (i - 1))) continue; foreach (j; 1 .. N + 1) { if (s & (1 << (j - 1))) continue; chmax(dp[s | (1 << (i - 1)) | (1 << (j - 1))], dp[s] + cst[i][j]); } } long ret = dp[(1 << N) - 1]; writeln(ret); }