n,k = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)
b = Array.new
m = n*(n+1)/2

sum = 0
for i in 0..n-1
    sum = 0
    for j in i..n-1
        sum += a[j]
        b.push(sum)
    end
end

ret = 0
cnt = 0
used = Array.new(m,true)
41.downto(1) do |i|
    t = 1 << i
    for j in 0..m-1
        b[j] %= t
    end
    cnt = 0
    temp = Array.new(m,true)
    for j in 0..m-1
        cnt += 1 if b[j] >= (t >> 1) && used[j]
    end

    if cnt >= k
        for j in 0..m-1
            used[j] = false if (b[j] < (t >> 1))
        end
        ret += (t >> 1)
    end
end
puts ret