#include <bits/stdc++.h>

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

int N;

int f(int i, std::vector<int> &&A){
    if(i < 0){
        return 0;
    }

    std::vector<int> B[2];

    for(int a : A){
        B[a >> i & 1].emplace_back(a);
    }

    if(B[0].size() == 0){
        return f(i - 1, std::move(B[1]));
    }

    if(B[1].size() == 0){
        return f(i - 1, std::move(B[0]));
    }

    int x0 = f(i - 1, std::move(B[0])), x1 = f(i - 1, std::move(B[1]));
    return std::min(std::max((1 << i) + x0, x1), std::max(x0, (1 << i) + x1));
}

int main(){
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);

    std::cin >> N;

    std::vector<int> A(N);

    for(int i=0;i<N;++i){
        std::cin >> A[i];
    }

    int x = f(29, std::move(A));
    std::cout << x << std::endl;
}