import Data.Bool
import Data.List

solve :: Int -> Int -> [Int] -> Int
solve n k a = fst $ foldr f (0, sums) [0..39] where
  f e (c,sums)
    | cnt (c+2^e) >= k = (c+2^e, filter (>=2^e) sums)
    | otherwise = (c, sums)
  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