You are given a complete undirected graph with *n* vertices. A number *a*<sub class="lower-index">*i*</sub> is assigned to each vertex, and the weight of an edge between vertices *i* and *j* is equal to *a*<sub class="lower-index">*i*</sub> *xor* *a*<sub class="lower-index">*j*</sub>.

Calculate the weight of the minimum spanning tree in this graph.
The first line contains *n* (1 ≤ *n* ≤ 200000) — the number of vertices in the graph.

The second line contains *n* integers *a*<sub class="lower-index">1</sub>, *a*<sub class="lower-index">2</sub>, ..., *a*<sub class="lower-index">*n*</sub> (0 ≤ *a*<sub class="lower-index">*i*</sub> &lt; 2<sup class="upper-index">30</sup>) — the numbers assigned to the vertices.
none
5
1 2 3 4 5
8
4
1 2 3 4
8
1
1
0
# LUOGU_RID: 100250825
class trie:
	def __init__(self):
		self.ch=[None,None]
	def add(self,s):
		cur=self
		for i in s:
			if not cur.ch[int(i)]:
				cur.ch[int(i)]=trie()
			cur=cur.ch[int(i)]
	def MST(self):
		tot=0
		if self.ch[0]:
			tot=self.ch[0].MST()
		if self.ch[1]:
			tot+=self.ch[1].MST()
		if self.ch[0] and self.ch[1]:
			tot+=int("1"+bestedge(self.ch[0],self.ch[1]),base=2)
		return tot
def bestedge(p,q):
	res="2"
	if p.ch[0] and q.ch[0] or p.ch[1] and q.ch[1]:
		if p.ch[0] and q.ch[0]:
			res='0'+bestedge(p.ch[0],q.ch[0])
		if p.ch[1] and q.ch[1]:
			res=min(res,'0'+bestedge(p.ch[1],q.ch[1]))
		return res
	if p.ch[0] and q.ch[1]:
		res='1'+bestedge(p.ch[0],q.ch[1])
	if p.ch[1] and q.ch[0]:
		res=min(res,'1'+bestedge(p.ch[1],q.ch[0]))
	if res=="2":
		return ""
	return res
T=trie()
n=int(input())
for i in map(int,input().split()):
	T.add(bin(i+(2**5))[2:])
print(T.MST())