#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization("unroll-loops")
using namespace std;
const long long MOD = 1e+9 + 7;
const long long INF = 0x7f7f7f7f7f7f7f7f;
const int INFi = 0x7f7f7f7f;
const long long MAXN = 1e+5 + 7;
vector<long long> adj[MAXN];
long long visit[MAXN] = {};
int dx8[] = {0, 1, 1, 1, 0, -1, -1, -1}, dy8[] = {1, 1, 0, -1, -1, -1, 0, 1};
int dx4[] = {0, 1, 0, -1}, dy4[] = {1, 0, -1, 0};
int t = 1;
const int ALPHABET_SIZE = 2;
struct TrieNode {
  struct TrieNode* children[2];
  bool isEndOfWord;
};
struct TrieNode* getNode() {
  struct TrieNode* pNode = new TrieNode;
  pNode->isEndOfWord = false;
  for (long long i = 0; i < ALPHABET_SIZE; i++) pNode->children[i] = NULL;
  return pNode;
}
void insert(struct TrieNode* root, string key) {
  struct TrieNode* pCrawl = root;
  for (long long i = 0; i < key.length(); i++) {
    long long index = key[i] - '0';
    if (!pCrawl->children[index]) pCrawl->children[index] = getNode();
    pCrawl = pCrawl->children[index];
  }
  pCrawl->isEndOfWord = true;
}
bool isEmpty(TrieNode* root) {
  for (long long i = 0; i < ALPHABET_SIZE; i++) {
    if (root->children[i]) return false;
  }
  return true;
}
string decToBinary(long long n) {
  string second;
  for (long long i = 31; i >= 0; i--) {
    long long k = n >> i;
    if (k & 1)
      second += "1";
    else
      second += "0";
  }
  return second;
}
string use;
long long res = INF;
long long tmp = 0;
void dfs(struct TrieNode* root, long long d) {
  if (root->isEndOfWord) {
    res = min(res, tmp);
    return;
  } else if (root->children[0] && root->children[1]) {
    tmp += pow(2, d);
    dfs(root->children[0], d - 1);
    dfs(root->children[1], d - 1);
    tmp -= pow(2, d);
  } else if (root->children[0]) {
    dfs(root->children[0], d - 1);
  } else {
    dfs(root->children[1], d - 1);
  }
}
void MAIN() {
  long long n;
  cin >> n;
  TrieNode* T = getNode();
  vector<long long> a(n + 8);
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
    insert(T, decToBinary(a[i]));
  }
  dfs(T, 31);
  cout << res;
  cout << "\n";
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cout << fixed;
  cout << setprecision(10);
  ;
  mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
  ;
  while (t--) {
    MAIN();
  }
}
