// Goで1秒かかるのかー・・・ package main import ( "bufio" "fmt" "os" "strconv" ) func pow(x, y int) int { r := 1 for i := 0; i < y; i++ { r *= x } return r } func calc(a []int, b int) int { if b < 0 { return a[0] } mask := pow(2, b) p0 := make([]int, 0) p1 := make([]int, 0) for i := 0; i < len(a); i++ { num := a[i]; if num & mask == 0 { p0 = append(p0, num) } else { p1 = append(p1, num) } } if len(p0) == 0 { for i := 0; i < len(p1); i++ { p1[i] ^= mask; } return calc(p1, b - 1) } else if len(p1) == 0 { return calc(p0, b - 1) } else { for i := 0; i < len(p0); i++ { p0[i] ^= mask; } v1 := calc(p0, b - 1) v2 := calc(p1, b - 1) if v1 < v2 { return v1 } else { return v2 } } } func main() { sc := bufio.NewScanner(os.Stdin) sc.Split(bufio.ScanWords) sc.Scan(); n, _ := strconv.Atoi(sc.Text()) a := make([]int, n) for i := 0; i < n; i++ { sc.Scan(); num, _ := strconv.Atoi(sc.Text()) a[i] = num } fmt.Println(calc(a, 30)) }