N, K = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)
b = []
N.times { |i| (1..(N - i)).each { |j| b.push(a[i, j].inject(:+)) } }
d = b.max.to_s(2).size
b = b.map { |ai| ("%0#{d}d" % ai.to_s(2)).split("").map(&:to_i) }

def check_digit(arr, k, digit)
  arr.select { |ai| ai[digit] == 1 }.size >= k ? 1 : 0
end

max = 0

d.times do |i|
  if check_digit(b, K, i) == 1
    max += 2**(d - i - 1)
    b.select! { |ai| ai[i] == 1 }
  end
end

puts max