#include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; using ll = long long; class range {private: struct I{int x;int operator*(){return x;}bool operator!=(I& lhs){return x ostream& operator<<(ostream& os, const pair& p){ return os << "{" << p.first << ", " << p.second << "}"; } template ostream& operator<<(ostream& os, const vector& obj) { os << "{"; for (const auto& e : obj) os << e << ", "; return os << "}"; } template ostream& operator<<(ostream& os, const set& obj) { os << "set{"; for (const auto& e : obj) os << e << ", "; return os << "}"; } template ostream& operator<<(ostream& os, const map& obj) { os << "map{"; for (const auto& e : obj) os << e << ", "; return os << "}"; } #ifdef ONLINE_JUDGE #define dump(expr) ; #else #define dump(expr) { cerr << "\033[33m#L" << __LINE__ << ": " << expr << "\033[39m" << endl; } #endif struct T { T *zero, *one; T() : zero(nullptr), one(nullptr) {}; }; const int N = 31; ll dp(T* now, int h) { if (now == nullptr) return 0; if (now->zero && now->one) { dump(now << " " << h); return (1LL << h) + min(dp(now->zero, h - 1), dp(now->one, h - 1)); } return dp(now->zero, h - 1) | dp(now->one, h - 1); } ll solve() { int n; cin >> n; T* par = new T(); while (n--) { ll x; cin >> x; T* now = par; for (int i : range(N)) { if (x & (1LL << (N - 1 - i))) { if (now->one == nullptr) now->one = new T(); now = now->one; } else { if (now->zero == nullptr) now->zero = new T(); now = now->zero; } } } ll res = dp(par, N - 1); return res; } int main() { cout << fixed << setprecision(12); cout << solve() << endl; }