module main; // https://kmjp.hatenablog.jp/entry/2015/01/17/0900 より // ビット演算 import std; int f(int d, int[] v) { if (v.length <= 1) return 0; int i, j; auto w = new int[][](2); foreach (x; v) { w[(x >> d) & 1] ~= x ^ (x & (1 << d)); } if (w[0].empty) return f(d - 1, w[1]); if (w[1].empty) return f(d - 1, w[0]); return (1 << d) + min(f(d - 1, w[0]), f(d - 1, w[1])); } void main() { // 入力 auto N = readln.chomp.to!int; auto A = readln.split.to!(int[]); // 答えの計算と出力 writeln(f(29, A.sort.uniq.array)); }