import Data.Bool
import Data.List

solve :: Int -> Int -> [Int] -> Int
solve n k a = foldl f 0 [39,38..0] where
  f c e = c + bool 0 (2^e) (cnt (c+2^e) >= k)
  cnt m = length $ filter (>= m) sums
  sums = concatMap (scanl1 (+)) $ init $ tails a 

main = do
  [n,k] <- readWords
  a <- readWords
  print $ solve n k a

readWords = map read . words <$> getLine