N,K,*A=`dd`.split.map(&:to_i)
s = [0]
A.each{ |a| s << (s[-1] + a)}
ss = (0..40).map{ [] }
(0...N).map{ |i| (i...N).map{ |j| s[j+1]-s[i] } }.flatten.each{ |s|
  (0..40).each{ |b| 
    if s & (1 << b) > 0
      ss[b] << s
    end
  }
}
(0..40).reverse_each{ |b|
  if ss[b].size >= K
    p ss[b].sort[-K..-1].inject(:&); exit
  end
}
p 0
