#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
long long qpow(long long a, long long b, long long m) {
  long long r = 1;
  a %= m;
  for (; b; b >>= 1) {
    if (b & 1) r = r * a % m;
    a = a * a % m;
  }
  return r;
}
const int inf = 0x7fffffff;
const int maxn = 1e5 + 10;
struct trie {
  int son[maxn * 32][3], val[maxn * 32], tot;
  int dp[maxn * 32];
  void init() {
    memset(dp, 0, sizeof(dp));
    memset(son, 0, sizeof(son));
    memset(val, 0, sizeof(val));
    tot = 0;
  }
  void ins(int x) {
    int rt = 0;
    for (int i = 30; i >= 0; i--) {
      int c = (x >> i) & 1;
      if (!son[rt][c]) son[rt][c] = ++tot;
      rt = son[rt][c];
    }
    val[rt] = x;
  }
  void dfs(int rt) {
    if (son[rt][0] && son[rt][1] == 0) {
      dp[son[rt][0]] = dp[rt] << 1;
      dfs(son[rt][0]);
    } else if (son[rt][0] == 0 && son[rt][1]) {
      dp[son[rt][1]] = dp[rt] << 1;
      dfs(son[rt][1]);
    } else if (son[rt][0] == 0 && son[rt][0] == 0) {
      return;
    } else {
      dp[son[rt][0]] = dp[rt] << 1 | 1;
      dp[son[rt][1]] = dp[rt] << 1 | 1;
      dfs(son[rt][0]);
      dfs(son[rt][1]);
    }
  }
  int res() {
    int mi = inf;
    for (int i = 1; i <= tot; i++) {
      if (son[i][0] == son[i][1] && son[i][0] == 0) mi = min(mi, dp[i]);
    }
    return mi;
  }
} T;
int main() {
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    int x;
    cin >> x;
    T.ins(x);
  }
  T.dfs(0);
  cout << T.res() << endl;
  return 0;
}
