N, K = gets.split.map(&:to_i)
as = gets.split.map(&:to_i)

bs = []
N.times do |i|
    sum = 0
    (i...N).each do |j|
        sum += as[j]
        bs.push(sum)
    end
end

ans = 0

40.downto(0) do |i|
    cand = ans + (1<<i)
    num = 0
    bs.each do |b|
        num += 1 if cand & b == cand
    end
    ans = cand if num >= K
end
puts ans