n,k=gets.split.map(&:to_i)
nn=n*(n+1)/2
a=gets.split.map(&:to_i)
l=[]
n.times do |i|
  c=a[i]
  l << c
  (i+1).upto(n-1) do |j|
    c+=a[j]
    l << c
  end
end
f=[1]*nn
cf=nn
t=2**29
ans=0
ff=f.dup
cff=cf
while t>0
  nn.times do |i|
    if ff[i]==1
      if l[i]<t
        ff[i]=0
        cff-=1
      end
    end
    l[i]%=t
  end
  if cff>=k
    f=ff.dup
    cf=cff
    ans+=t
  else
    ff=f.dup
    cff=cf
  end
  t/=2
end
puts ans
