#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
const long long inf = 1e9 + 7;
long long mod = 998244353;
vector<int> a;
int solve(vector<int> &b, int bit) {
  vector<int> l, r;
  if (b.size() == 0 || bit < 0) return 0;
  for (int i = 0; i < b.size(); i++) {
    if ((b[i] >> bit) & 1 == 1)
      l.push_back(b[i]);
    else
      r.push_back(b[i]);
  }
  if (l.size() == 0) return solve(r, bit - 1);
  if (r.size() == 0) return solve(l, bit - 1);
  return min(solve(l, bit - 1), solve(r, bit - 1)) + (1 << bit);
}
int main(void) {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    int x;
    scanf("%d", &x);
    a.push_back(x);
  }
  int ans = solve(a, 30);
  printf("%d\n", ans);
  return 0;
}
