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