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

num_ary = []
for i in 0..(ary.length-1)
  for j in (i+1)..(ary.length-1)
    tmp = 0
    for z in i..j
      tmp += ary[z]
    end
    num_ary << tmp
  end
end

num_ary.sort!{|a, b| b <=> a}


tmp_keta = (Math.log2(num_ary[0])).to_i
# 14→3

# tmp_keta目でK個数が取れるか確認
ans = 0
while tmp_keta >= 0
  tmp_ary = []
  flag = true
  for i in 0..(k-1)
    if num_ary[i]/(2**tmp_keta)==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
  end
  tmp_keta-=1
end
puts ans
