def solve(xs, ac) return ac if xs.size == 0 ys = xs.clone y = ys[0] ys.delete_at 0 ans = 0 ys.size.times do |i| zs = ys.clone z = ys[i] zs.delete_at i ans = [ans, solve(zs, (y + z) ^ ac)].max end ans end _ = gets.to_i xs = gets.split.map(&:to_i) p solve(xs, 0)