using System; using System.IO; using System.Collections.Generic; using System.Linq; namespace No698 { public class Program { int N; int[] A; int[] B; void Solve(StreamScanner ss, StreamWriter sw) { //--------------------------------- N = ss.Next(int.Parse); A = ss.Next(int.Parse, N / 2); B = ss.Next(int.Parse, N / 2); sw.WriteLine(Dfs(N / 2)); //--------------------------------- } int Dfs(int c) { if (c-- == 0) return Permute(); var ret = 0; ret = Math.Max(ret, Dfs(c)); MathX.Swap(ref A[c], ref B[c]); ret = Math.Max(ret, Dfs(c)); MathX.Swap(ref A[c], ref B[c]); return ret; } int Permute() { var a = A.OrderBy(x => x).ToArray(); var ans = 0; do { var power = 0; for (var i = 0; i < N / 2; i++) power ^= a[i] + B[i]; ans = Math.Max(ans, power); } while (MathX.NextPermutation(a)); return ans; } static void Main() { var ss = new StreamScanner(new StreamReader(Console.OpenStandardInput())); var sw = new StreamWriter(Console.OpenStandardOutput()) {AutoFlush = false}; new Program().Solve(ss, sw); sw.Flush(); } static readonly Func String = s => s; } public static partial class MathX { public static void Swap(ref T left, ref T right) { var tmp = left; left = right; right = tmp; } //From: https://stackoverflow.com/questions/11208446/generating-permutations-of-a-set-most-efficiently public static bool NextPermutation(int[] numList) { var largestIndex = -1; for (var i = numList.Length - 2; i >= 0; i--) { if (numList[i] < numList[i + 1]) { largestIndex = i; break; } } if (largestIndex < 0) return false; var largestIndex2 = -1; for (var i = numList.Length - 1; i >= 0; i--) { if (numList[largestIndex] < numList[i]) { largestIndex2 = i; break; } } Swap(ref numList[largestIndex], ref numList[largestIndex2]); for (int i = largestIndex + 1, j = numList.Length - 1; i < j; i++, j--) { Swap(ref numList[i], ref numList[j]); } return true; } } public class StreamScanner { static readonly char[] Sep = {' '}; readonly Queue buffer = new Queue(); readonly TextReader textReader; public StreamScanner(TextReader textReader) { this.textReader = textReader; } public T Next(Func parser) { if (buffer.Count != 0) return parser(buffer.Dequeue()); var nextStrings = textReader.ReadLine().Split(Sep, StringSplitOptions.RemoveEmptyEntries); foreach (var nextString in nextStrings) buffer.Enqueue(nextString); return Next(parser); } public T[] Next(Func parser, int x) { var ret = new T[x]; for (var i = 0; i < x; ++i) ret[i] = Next(parser); return ret; } public T[][] Next(Func parser, int x, int y) { var ret = new T[y][]; for (var i = 0; i < y; ++i) ret[i] = Next(parser, x); return ret; } } }