import Data.Bool
import Data.List

solve :: Int -> Int -> [Int] -> Int
solve n k a = go 0 40 where
  go c (-1) = c
  go c e
    | cnt (c+2^e) >= k = go (c+2^e) (e-1)
    | otherwise = go c (e-1)
  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