#include <bits/stdc++.h>
using namespace std;
bool isprime(long long n) {
  if (n == 1) return false;
  if (n == 2) return true;
  for (long long i = 2; i <= sqrt(n); i++) {
    if (n % i == 0) {
      return false;
    }
  }
  return true;
}
long long poww(long long b, long long e) {
  if (e == 0)
    return 1;
  else if (e % 2 == 0) {
    long long a = pow(b, e / 2);
    return a * a;
  } else {
    long long a = pow(b, e / 2);
    return b * a * a;
  }
}
long long powm(long long x, long long y, long long m = 1000000007) {
  x = x % m;
  long long res = 1;
  while (y) {
    if (y & 1) res = res * x;
    res %= m;
    y = y >> 1;
    x = x * x;
    x %= m;
  }
  return res;
}
long long modInverse(long long a, long long m = 1000000007) {
  return powm(a, m - 2, m);
}
void print(vector<long long> v) {
  for (long long i = 0; i < v.size(); i++) {
    cout << v[i] << " ";
  }
}
void print(long long arr[]) {
  long long size = *(&arr + 1) - arr;
  for (long long i = 0; i < size; i++) {
    cout << arr[i] << " ";
  }
}
string to_bin(long long n) {
  string res = "";
  long long i = 0;
  while (n > 0) {
    if (n % 2 == 1) {
      res = res + '1';
    } else {
      res = res + '0';
    }
    n /= 2;
    i++;
  }
  reverse(res.begin(), res.end());
  return res;
}
long long to_dec(string second) {
  long long n = second.size(), ans = 0, temp = 1;
  for (long long i = n - 1; i >= 0; i--) {
    long long x = second[i] - '0';
    ans += x * temp;
    temp *= 2;
  }
  return ans;
}
long long utsav(vector<long long> v, long long n, long long bit) {
  if (v.size() == 0) return 9e18;
  vector<long long> zero, one;
  for (long long i = 0; i < n; i++) {
    if ((v[i] >> bit) & 1) {
      one.push_back(v[i]);
    } else
      zero.push_back(v[i]);
  }
  if (bit == 0) {
    if (one.size() == 0 || zero.size() == 0) {
      return 0;
    } else
      return 1;
  }
  long long aone = utsav(one, one.size(), bit - 1);
  long long azero = utsav(zero, zero.size(), bit - 1);
  long long val = min(aone, azero);
  if (aone == 9e18 || azero == 9e18) {
  } else
    val += 1ll << bit;
  return val;
}
void solve() {
  long long n;
  cin >> n;
  vector<long long> arr(n);
  for (long long i = 0; i < n; i++) {
    cin >> arr[i];
  }
  cout << utsav(arr, n, 29);
}
int32_t main() {
  ios_base::sync_with_stdio();
  cin.tie(0);
  cout.tie(0);
  solve();
}
