N = int(raw_input()) a = map(int,raw_input().split()) x = (1 << 31)-1 mn = max(ai^x for ai in a) for i in xrange(30,-1,-1): xx = x ^ (1 << i) if max(ai^xx for ai in a) < mn: mn = max(ai^xx for ai in a) x = xx print mn