import Data.List
import Data.Word
import Data.Bits
import Control.Monad

diffs :: [Word64] -> [Word64]
diffs xs = flip concatMap (tails xs) $
  \ys ->
    case ys of
      [] -> []
      y : ys' -> map (\z -> z - y) ys'


filterMask :: Int -> Word64 -> [Word64] -> Maybe [Word64]
filterMask k mask xs = guard (length ys >= k) >> Just ys where
  ys = filter (\x -> mask .&. x == mask) xs
  
solve :: Int -> [Word64] -> Word64
solve k xs = rec (shiftL 1 63) 0 ds where
  ds = diffs (scanl (+) 0 xs)
  rec 0 acc _ = acc
  rec mask acc xs = 
    case filterMask k mask xs of
      Nothing -> rec (shiftR mask 1) acc xs
      Just xs' -> rec (shiftR mask 1) (acc .|. mask) xs'
      


main = do
  [n, k] <- (map read . words) <$> getLine
  xs <- (map read . words) <$> getLine
  print $ solve k xs
  return ()
