using System; using System.Linq; namespace ConsoleApplication2 { class Program { static void Main(string[] args) { var mask = Enumerable.Range(0, 31).Select(x => 1 << x).Reverse().ToArray(); Console.ReadLine(); var current = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray(); int[] candidate = new int[0]; foreach (var m in mask) { var currentMax = current.Max(); candidate = current.Select(x => x ^ m).ToArray(); var candidateMax = candidate.Max(); //current = currentMax > candidateMax ? candidate : current; if (currentMax > candidateMax) { current = candidate; } } Console.WriteLine(current.Max()); } } }