#include <bits/stdc++.h>
using namespace std;
struct node {
  int next[2];
  node() { next[0] = next[1] = -1; }
};
vector<node> a;
void add(string s) {
  int cur = 0;
  for (int i = 0; i < (int)(s).size(); i++) {
    if (a[cur].next[s[i] - '0'] != -1) {
      cur = a[cur].next[s[i] - '0'];
    } else {
      a[cur].next[s[i] - '0'] = (int)(a).size();
      cur = (int)(a).size();
      a.push_back(node());
    }
  }
}
int dfs(int v, int i = 29) {
  if (a[v].next[0] == -1 && a[v].next[1] == -1) return 0;
  if (a[v].next[0] == -1) return dfs(a[v].next[1], i - 1);
  if (a[v].next[1] == -1) return dfs(a[v].next[0], i - 1);
  return (1 << i) + min(dfs(a[v].next[0], i - 1), dfs(a[v].next[1], i - 1));
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
  int n;
  cin >> n;
  a.push_back(node());
  while (n--) {
    int a;
    cin >> a;
    string s;
    while (a > 0) {
      s.push_back(a % 2 + '0');
      a /= 2;
    }
    while ((int)(s).size() < 30) s.push_back('0');
    reverse((s).begin(), (s).end());
    add(s);
  }
  cout << dfs(0);
  return 0;
}
