{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}
import qualified Data.ByteString.Lazy.Char8 as B
import Data.Maybe
import Data.List
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM
import Control.Monad

solve :: Int -> Int -> [Int] -> Int
solve n k as = value 0 seq
  where

    size = n * (n+1) `div` 2
    acc = VU.fromList $ scanl' (+) 0 as
    subsum = [(acc VU.! i) - (acc VU.! j) | j <- [0..n], i <- [j+1..n]]
    table = VU.fromList $ concatMap int2bits subsum

    enc k p = (k * 32) + p

    valid0 = replicate size 1

    seq = unfoldr f (valid0, 31)
      where
      f (valid, -1) = Nothing
      f (valid, p) = ans
        where
          nxt = zipWith (*) valid col
          col = [table VU.! (enc k p) | k <- [0..size-1]]
          ans | sum nxt >= k = Just (1, (nxt, p-1))
              | otherwise    = Just (0, (valid, p-1))

    value acc [] = acc
    value acc (b:bs) = value (2*acc + b) bs

int2bits :: Int -> [Int]
int2bits x = take 32 $ unfoldr f x
  where
    f y = Just (q, p)
      where (p,q) = divMod y 2


readBInt :: B.ByteString -> Int
readBInt = fst . fromJust . B.readInt

tmain :: B.ByteString -> Int
tmain cont =
  let remLines0 = map B.words (B.lines cont)
      [bs_n,bs_k]:remLines1 = remLines0
      n = readBInt bs_n
      k = readBInt bs_k
      line2:remLines2 = remLines1
      as = map readBInt line2
  in solve n k as

outAnswer :: Int -> IO ()
outAnswer = putStrLn . show

main :: IO ()
main = outAnswer . tmain =<< B.getContents
