N = int(input()) a = list(map(int,input().split())) def calc(now,l,b): if b == -1: return now one = [] zero = [] mask = 1 << b for i in l: if i & mask: one.append(i) else: zero.append(i) if len(one) == 0 or len(zero) == 0: return calc(now,l,b-1) else: t1 = calc(now | mask,one,b-1) t2 = calc(now | mask,zero,b - 1) return min(t1,t2) print(calc(0,a,30))