#include <bits/stdc++.h>
using namespace std;
int solve(vector<int> &A, int bit) {
  if (bit < 0) return 0;
  vector<int> on, off;
  for (int &x : A) {
    if (x & (1 << bit))
      on.push_back(x);
    else
      off.push_back(x);
  }
  if (on.empty())
    return solve(off, bit - 1);
  else if (off.empty())
    return solve(on, bit - 1);
  return (1 << bit) + min(solve(off, bit - 1), solve(on, bit - 1));
}
int main() {
  int n;
  cin >> n;
  vector<int> A(n);
  for (int i = 0; i < n; i++) cin >> A[i];
  cout << solve(A, 30);
}
