DBG = !true
n,k = gets.split.map{|x| x.to_i}
a = gets.split.map{|x| x.to_i}
s = []
for i in 0...n
  sum = 0
  for j in i...n
    sum += a[j]
    s << sum
  end
end

if DBG
  printf("n:%d k:%d\n", n, k)
  puts "s ---"
  print s
  puts ""
end

prod = 0
while true
  puts "in while loop" if DBG

  40.downto(0) { |i|
    c = []
    for x in s
      c << x if (1 << i) & x != 0
    end
    if c.size >= k
      prod |= (1 << i)
      s = c
      if DBG
        printf("bit on, i:%d post s:\n", i)
        print s
        puts ""
      end
    end
  }
  print prod
  exit
end
