n, k = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)

b = []
n.times do |i|
    b << a[i]
    (i+1).upto(n-1) {|j| b << b[-1] + a[j]}
end

ans = 0
41.downto(0) do |i|
    x = 1 << i
    y = b.select{|e| e & x != 0}
    if y.size >= k
        ans += x
        b = y
    end
end

p ans