#include #include #include #include #include #include #include #include #include #include static const int MOD = 1000000007; using ll = long long; using u32 = uint32_t; using namespace std; template constexpr T INF = ::numeric_limits::max()/32*15+208; struct Node { int val; Node *l, *r; Node() : val(0), l(nullptr), r(nullptr) {} }; template struct Binarytrie { Node *root; Binarytrie() { root = new Node; } void add(const T b, int x = 1){ Node *p = root; for (int i = X-1; i >= 0; --i) { bool f = (b >> i) & 1; if(!f && !p->l) p->l = new Node; if(f && !p->r) p->r = new Node; p = (f ? p->r : p->l); } p->val += x; } }; int main() { int n; cin >> n; Binarytrie tree; for (int i = 0; i < n; ++i) { int x; scanf("%d", &x); tree.add(x); } auto rec = [&](int X, Node* p, auto &&f) -> int { if(!p) return 0; if(!p->l) return f(X-1, p->r, f); if(!p->r) return f(X-1, p->l, f); return min(f(X-1, p->r, f), f(X-1, p->l, f)) + (1 << X); }; cout << rec(30, tree.root, rec) << "\n"; return 0; }