#include <bits/stdc++.h>
using namespace std;
const long long N = 200010;
const long long mod = 1e9 + 7;
const long long inf = 1e9;
inline long long read() {
  long long p = 0;
  long long f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f *= -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    p = p * 10 + ch - '0';
    ch = getchar();
  }
  return p * f;
}
long long a[N];
long long n;
long long rt, tt = 0;
long long lc[N * 32], rc[N * 32];
void build(long long x) {
  long long u = rt;
  for (long long i = 30; i >= 0; i--) {
    if (x & (1ll << i)) {
      if (!rc[u]) rc[u] = ++tt;
      u = rc[u];
    } else {
      if (!lc[u]) lc[u] = ++tt;
      u = lc[u];
    }
  }
}
long long qry(long long u, long long x) {
  if (!lc[u] && !rc[u])
    return 0;
  else if (!lc[u])
    return qry(rc[u], x - 1);
  else if (!rc[u])
    return qry(lc[u], x - 1);
  else
    return (1ll << x) + min(qry(lc[u], x - 1), qry(rc[u], x - 1));
}
int main() {
  n = read();
  rt = tt = 1;
  for (long long i = 1; i <= n; i++) a[i] = read(), build(a[i]);
  return printf("%lld\n", qry(rt, 30)), 0;
}
