#coding: utf-8 ##yuki_130 n=int(raw_input()) a=map(int,raw_input().split()) #print a res=[] for i in xrange(max(a)+1): s=a[:] for j in xrange(len(s)): s[j]=s[j]^i # print i,s,max(s) res.append(max(s)) # print res print min(res)