import std.algorithm, std.array, std.container, std.range, std.bitmanip; import std.numeric, std.math, std.bigint, std.random, core.bitop; import std.string, std.regex, std.conv, std.stdio, std.typecons; void main() { auto n = readln.chomp.to!size_t; auto ai = readln.split.map!(to!size_t).array; writeln(calc(ai)); } size_t calc(size_t[] ai) { if (ai.length == 1) { return 0; } else { auto maxA = ai.reduce!(max); if (maxA == 0) return 0; auto b = maxA.bsr; auto si = ai.filter!(a => bt(&a, b)).map!(a => a ^ (1 << b)).array; auto ri = ai.filter!(a => !bt(&a, b)).array; if (si.length == 0) { return calc(ri); } else if (ri.length == 0) { return calc(si); } else { return min(calc(si), calc(ri)) | (1 << b); } } }