#include <bits/stdc++.h>
using namespace std;
long long n, arr[100005] = {0}, bin[100005][31] = {0};
long long power(long long x, long long m) {
  if (m == 0) return 1;
  long long temp = power(x, m / 2);
  if (m % 2 == 1)
    return temp * temp * x;
  else
    return temp * temp;
}
long long recur(long long s, long long e, long long k) {
  long long i;
  if (s == e) return 0;
  for (i = s; i <= e; i++) {
    if (bin[i][k] == 1) break;
  }
  if (k == 30) {
    if (i > s && i <= e)
      return 1;
    else
      return 0;
  }
  if (i > s && i <= e)
    return power(2, 30 - k) + min(recur(s, i - 1, k + 1), recur(i, e, k + 1));
  else
    return recur(s, e, k + 1);
}
int main() {
  long long i, j;
  cin >> n;
  for (i = 1; i <= n; i++) cin >> arr[i];
  arr[0] = 0;
  sort(arr, arr + n + 1);
  for (i = 1; i <= n; i++) {
    for (j = 30; j > 0; j--) {
      bin[i][j] = arr[i] % 2;
      arr[i] /= 2;
    }
  }
  long long ans = recur(1, n, 1);
  cout << ans;
}
