y,a[1<<17];c(int*a,int*b){y=*a-*b;}x(s,n,i){int l=s,u=n,m;for(;u-l>1;a[m=l+u>>1]&i?u=m:(l=m));y=i?(a[s]^a[n-1])&i?i|((l=x(s,u,i/2))<(m=x(u,n,i/2))?l:m):x(s,n,i/2):0;}main(n){for(n=-2;~scanf("%d",++n+a););qsort(a,n,4,c);y=!printf("%d",x(0,n,1<<29));}