_n,k = gets.chomp.split.map(&:to_i)
ary = gets.chomp.split.map(&:to_i)

num_ary = []
ruisekiwa = [ary[0]]
for i in 1..(ary.length-1)
  ruisekiwa[i] = ruisekiwa[i-1]+ary[i]
end
for i in 0..(ary.length-1)
  for j in (i+1)..(ary.length-1)
    if i == 0
      num_ary << ruisekiwa[j]
    else
      num_ary << ruisekiwa[j]-ruisekiwa[i-1]
    end
  end
end
num_ary.sort!{|a, b| b <=> a}
tmp_keta = (Math.log2(num_ary[0])).to_i
# 14→3
# tmp_keta目でK個1が取れるか確認
ans = 0
while tmp_keta >= 0
  tmp_ary = []
  # flag = true
  count = 0
  num_ary.each do |item|
    if (item >> tmp_keta) & 1 == 1
      count += 1
      tmp_ary << item
    end
  end
  if count >= k
    ans += 2**tmp_keta
    num_ary = tmp_ary
  end
  # p num_ary
  tmp_keta -= 1
end
puts ans






  # for i in 0..(k-1)
  #   if (num_ary[i]>>tmp_keta)&1 == 1
  #     tmp_ary << num_ary[i]-2**tmp_keta
  #   else
  #     flag = false
  #     break
  #   end
  # end
  # if flag
  #   ans += 2**tmp_keta
  #   num_ary = tmp_ary.sort!{|a, b| b <=> a}
  # else
  #   for i in 0..(num_ary.length-1)
  #     num_ary[i] -= 2**tmp_keta
  #   end
  #   num_ary.sort!{|a, b| b <=> a}
  # end
  # tmp_keta-=1
# end
# puts ans
