#include <bits/stdc++.h>
using namespace std;
int rec(vector<int> A, int p) {
  if (p == -1) return 0;
  vector<int> B, C;
  for (auto x : A) {
    if (x & (1 << p))
      B.push_back(x & ~((1 << p)));
    else
      C.push_back(x & ~((1 << p)));
  }
  if (A.size() == B.size()) {
    return rec(B, p - 1);
  } else if (A.size() == C.size()) {
    return rec(C, p - 1);
  } else {
    return (1 << p) + min(rec(B, p - 1), rec(C, p - 1));
  }
  return 0;
}
int main() {
  int n;
  cin >> n;
  vector<int> A(n);
  for (int i = 0; i < n; i++) {
    cin >> A[i];
  }
  cout << rec(A, 30) << endl;
}
