#include <bits/stdc++.h>
using namespace std;
struct node {
  map<char, node *> mp;
  bool is = false;
};
void insert(node *root, string &s) {
  for (int i = 0; i < s.length(); i++) {
    if (root->mp[s[i]] == NULL) {
      root->mp[s[i]] = new node();
      root = root->mp[s[i]];
    } else
      root = root->mp[s[i]];
  }
  root->is = true;
}
bool search(node *root, string &s) {
  for (int i = 0; i < s.length(); i++) {
    if (root->mp[s[i]] == NULL)
      return false;
    else
      root = root->mp[s[i]];
  }
  if (root->is == false)
    return false;
  else
    return true;
}
string func(int n) {
  string res(30, '0');
  int i = 0;
  while (n) {
    res[i] = n % 2 + '0';
    n /= 2;
    i++;
  }
  reverse(res.begin(), res.end());
  return res;
}
int cal(node *root, int cnt) {
  if (root->mp['0'] != NULL && root->mp['1'] != NULL) {
    return (1 << (cnt - 1)) +
           min(cal(root->mp['0'], cnt - 1), cal(root->mp['1'], cnt - 1));
  } else if (root->mp['0'] != NULL) {
    return cal(root->mp['0'], cnt - 1);
  } else if (root->mp['1'] != NULL)
    return cal(root->mp['1'], cnt - 1);
  else
    return 0;
}
int main() {
  node *root = new node();
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    string s = func(x);
    insert(root, s);
  }
  int res = cal(root, 30);
  cout << res << endl;
  return 0;
}
