#include <bits/stdc++.h>
using namespace std;
int mod = 998244353;
const long long INF = 1ll << 60;
const int maxn = 1e5 + 10;
const int maxl = 1 << 10;
const double pi = acos(-1.0);
const double eps = 1e-8;
int n;
int po[maxn << 5];
int son[maxn << 5][2];
int cnt;
int a[maxn];
const int dd = 29;
void insert(int x) {
  int c = 0;
  for (int i = dd; i >= 0; --i) {
    int u = (x >> i) & 1;
    if (!son[c][u]) son[c][u] = ++cnt;
    po[c] = i;
    c = son[c][u];
  }
}
int ans[maxn << 5];
void dfs(int u) {
  int cn = 0;
  for (int t = (0); t < (2); ++t) cn += (!!son[u][t]);
  if (!cn) return;
  if (cn == 1) {
    for (int t = (0); t < (2); ++t) {
      if (son[u][t]) {
        dfs(son[u][t]);
        ans[u] = ans[son[u][t]];
        return;
      }
    }
  }
  for (int t = (0); t < (2); ++t) dfs(son[u][t]);
  ans[u] = (1 << po[u]) + min(ans[son[u][0]], ans[son[u][1]]);
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n;
  for (int t = (0); t < (n); ++t) cin >> a[t], insert(a[t]);
  dfs(0);
  cout << ans[0];
}
