use proconio::input; fn main() { input! { n:usize, a:[usize;n], } const D: usize = 16; if n >= D { let ans = (1 << 16) - 1; println!("{}", ans); return; } let mut dp = vec![vec![false; 1 << D]; n + 1]; dp[0][0] = true; for i in 0..n { for j in 0..1 << D { if !dp[i][j] { continue; } let mut x = a[i]; for _ in 0..D { dp[i + 1][j | x] = true; x = shift(x); } } } for i in (0..1 << D).rev() { if dp[n][i] { let ans = i; println!("{}", ans); return; } } } fn shift(x: usize) -> usize { if x & 1 == 0 { x >> 1 } else { (x >> 1) | (1 << 15) } }