def rec(x,i,mn): if i < 0: return mn res = mn xx = x | (1 << i) tmp = max(ai^xx for ai in a) if tmp < mn: res = min(res, rec(xx,i-1,tmp)) elif tmp == mn: res = min(res, rec(xx,i-1,mn), rec(x,i-1,mn)) else: res = min(res, rec(x,i-1,mn)) return res N = int(raw_input()) a = map(int,raw_input().split()) mn = max(a) print rec(0,30,mn)