$bag = []

def size i
    j = load = 0
    needTrack = 1
    for $k in j...$bag.size
        load += $bag[$k]
        if (i < load)
            load = $bag[$k]
            needTrack += 1
        end
    end
    return needTrack
end

BagNum, TrackNum = gets.split.map &:to_i
BagNum.times {$bag << gets.to_i}

p ($bag.max..10**9).bsearch{|i|
    size(i) <= TrackNum
}