Scanf.scanf "%d %d" (fun n k ->
    let a = Array.init n (fun _ -> Scanf.scanf " %d" (fun a -> a)) in

    let d = Array.make (n + 1) 0 in
    for i = 1 to n do
        d.(i) <- d.(i - 1) + a.(i - 1)
    done;

    let lim = n * (n + 1) / 2 in
    let s = Array.make lim 0 in
    let rec loop_i i idx =
        let rec loop_j j idx =
            if j > n then loop_i (i + 1) idx else
                let () = s.(idx) <- d.(j) - d.(i) in
                loop_j (j + 1) (idx + 1)
        in
        if i = n then () else
            loop_j (i + 1) idx
    in
    loop_i 0 0;

    let rec loop s s2 lim target t2 i acc =
        if t2 = 0 then target else
        if i = lim then (
            let t3 = t2 lsr 1 in
            if acc >= k then loop s2 (Array.make acc 0) acc (target lor t3)         t3 0 0
                        else loop s  s2                 lim (target lor t3 lxor t2) t3 0 0
        ) else
            if s.(i) land target = target then (
                s2.(acc) <- s.(i);
                loop s s2 lim target t2 (i + 1) (acc + 1)
            ) else (
                loop s s2 lim target t2 (i + 1) acc
            )
    in
    let s2 = Array.make lim 0 in
    let target = loop s s2 lim (1 lsl 40) (1 lsl 40) 0 0 in
    Printf.printf "%d\n" target
)