local n, k = io.read("*n", "*n")
local a = {}
for i = 1, n do a[i] = io.read("*n") end
local sum = {}
local cursum = 0

local function addsub(curval, i)
  for j = 1, i - 1 do
    curval = curval - a[j]
    table.insert(sum, curval)
  end
end

for i = 1, n do
  cursum = cursum + a[i]
  table.insert(sum, cursum)
  addsub(cursum, i)
end
local mfl = math.floor
local function challenge(tbl, div)
  local cnt = 0
  local tn = #tbl
  for i = 1, tn do
    local v = mfl(tbl[i] / div)
    if v % 2 == 1 then
      cnt = cnt + 1
    end
  end
  if cnt < k then
    return false, tbl
  else
    local newtbl = {}
    for i = 1, tn do
      local v = mfl(tbl[i] / div)
      if v % 2 == 1 then
        table.insert(newtbl, tbl[i])
      end
    end
    return true, newtbl
  end
end

local mul = 2^40
local result = 0
for i = 0, 40 do
  ret, sum = challenge(sum, mul)
  if ret then
    result = result + mul
  end
  mul = mul / 2
end
print(result)
