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