use std::io::Read; fn calc(a: &[u32], k: u32) -> u32 { if a.len() <= 1 || k == 0 { return 0; } let k = k - 1; if (a[0] ^ a.last().unwrap()) >> k & 1 == 0 { calc(a, k) } else { let x = a.iter().position(|a| *a >> k & 1 == 1).unwrap(); let p = a.split_at(x); std::cmp::min(calc(p.0, k), calc(p.1, k)) + (1 << k) } } fn run() { let mut s = String::new(); std::io::stdin().read_to_string(&mut s).unwrap(); let mut it = s.trim().split_whitespace(); it.next(); let mut a: Vec = it.map(|s| s.parse().unwrap()).collect(); a.sort(); let ans = calc(&a, 30); println!("{}", ans); } fn main() { run(); }