class TrieNode:
def __init__(self):
self.next = [None, None]
class Trie:
def __init__(self):
self.root = TrieNode()
def append(self, s: str):
cur = self.root
for ch in s:
idx = 0 if ch == '0' else 1
if cur.next[idx] is None:
new_node = TrieNode()
cur.next[idx] = new_node
cur = cur.next[idx]
def getRoot(self) -> TrieNode:
return self.root
def dfs(dep, max_dep, node1: TrieNode, node2: TrieNode) ->int:
if dep == max_dep:
return 0
max_val = 0
flag = False
if node1.next[1] is not None and node2.next[0] is not None:
flag = True
max_val = max(max_val, dfs(dep+1, max_dep, node1.next[1], node2.next[0]))
if node1.next[0] is not None and node2.next[1] is not None:
flag = True
max_val = max(max_val, dfs(dep+1, max_dep, node1.next[0], node2.next[1]))
if flag:
ans = max_val | (1 << (max_dep-1-dep))
return ans
if node1.next[0] is not None:
return dfs(dep+1, max_dep, node1.next[0], node2.next[0])
else:
return dfs(dep+1, max_dep, node1.next[1], node2.next[1])
n = int(input())
arr = list( map(int, input().split()) )
trie = Trie()
max_len = 0
ss = []
for val in arr:
s = '{:b}'.format(val)
max_len = max(max_len, len(s))
ss.append(s)
for s in ss:
s = '0' * (max_len - len(s)) + s
trie.append(s)
print(dfs(0, max_len, trie.root, trie.root))