import sequtils,strutils,algorithm,math var N = stdin.readline.parseInt A2 = stdin.readline.split.map(parseInt) flag : array[100001, bool] proc solve(d : int, A : openarray[int]) : int = if A.len <= 1 or d == 0: return 0 var B = newSeqWith(2, newSeq[int](0)) for a in A: B[((a shr d) and 1)].add(a - (1 shl d)) if B[0].len == 0: return solve(d - 1, B[1]) elif B[1].len == 0: return solve(d - 1, B[0]) else: return (1 shl d) + min(solve(d - 1, B[0]), solve(d - 1, B[1])) echo solve(29, A2)