#include<iostream>
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
const int N = 100010, M = 3000000;
int son[M][2], idx, a[N];
void insert(int x){
int p =0;
for(int i = 30;~i;--i){
int &s = son[p][x >> i & 1];
if(!s)s = ++idx;
p = s;
}
}
int query(int x){
int p =0;
int res = 0;
for(int i = 30;~i;--i){
int s = x >> i & 1;
if(son[p][!s]){
res += 1<<i;
p = son[p][!s];
}
else p = son[p][s];
}
return res;
}
int main(){
int n;cin >> n;
for(int i =0;i<n;++i){
scanf("%d",&a[i]);
insert(a[i]);
}
int ans =0;
for(int i = 0;i<n;++i){
ans = max(ans,query(a[i]));
}
printf("%d\n",ans);
return 0;
}