def check(p,arr,k,n)
    i = 0
    j = 0
    while j < k
        s = 0
        while s +arr[i] <= p
            s +=arr[i]
            i += 1
            if i == n
                return n
            end
        end
        j +=1
    end
    return i
end

def solve(arr,k,n)
    left = 0
    right = 100000 * 100000
    while (right - left > 1)
        mid = (right+left)/2
        v =check(mid,arr,k,n)
        if v >= n
            right = mid 
        else
            left =mid
        end
    end
    return right
end

n, k = gets.split.map(&:to_i)
arr=[]
n.times do 
    obj = gets.to_i
    arr << obj
end

ans = solve(arr,k,n)

puts ans
