using System; using System.Collections; using System.Collections.Generic; using System.IO; using System.Linq; namespace ConsoleApplication2 { class Program { static void Main(string[] args) { #if LOCAL Console.SetIn(new StreamReader("test04.txt")); #endif var mask = Enumerable.Range(0, 32).Select(x => (uint)1 << x).Reverse().ToArray(); Console.ReadLine(); var current = Console.ReadLine().Split().Select(x => uint.Parse(x)).ToArray(); uint[] candidate = new uint[0]; foreach (var m in mask.Reverse()) { var currentMax = current.Max(); candidate = current.Select(x => x ^ m).ToArray(); var candidateMax = candidate.Max(); if (currentMax > candidateMax) { current = candidate; } } Console.WriteLine(current.Max()); } } }