#include <bits/stdc++.h>
using namespace std;
template <class T>
inline void read(T &ret) {
  char c;
  int sgn;
  if (c = getchar(), c == EOF) return;
  while (c != '-' && (c < '0' || c > '9')) c = getchar();
  sgn = (c == '-') ? -1 : 1;
  ret = (c == '-') ? 0 : (c - '0');
  while (c = getchar(), c >= '0' && c <= '9') ret = ret * 10 + (c - '0');
  ret *= sgn;
  return;
}
int n, x;
int dfs(vector<int> c, int bit) {
  if (bit < 0) return 0;
  vector<int> in0, in1;
  for (int i = 0; i < c.size(); i++) {
    if (((c[i] >> bit) & 1) == 0)
      in0.push_back(c[i]);
    else
      in1.push_back(c[i]);
  }
  if (in0.size() == 0) return dfs(in1, bit - 1);
  if (in1.size() == 0) return dfs(in0, bit - 1);
  return min(dfs(in0, bit - 1), dfs(in1, bit - 1)) + (1 << bit);
}
int main() {
  vector<int> v;
  read(n);
  for (int i = 0; i < n; i++) {
    read(x);
    v.push_back(x);
  }
  printf("%d", dfs(v, 30));
  return 0;
}
