var n,k,w = new Array(100000);


function judge(p){
    i = 0;
    for(var j = 0;j < k;j++){
        var sum = 0;
        while(i < n && sum + w[i] <= p)
            sum += w[i++];
    }
    if(i == n)
        return true;
    else
        return false
}


function Main(input){
    input = input.split("\n");

    input[0] = input[0].split(" ");
    n = parseInt(input[0][0],10);
    k = parseInt(input[0][1],10);
    for(var i = 1;i <= n;i++){
        w[i - 1] = parseInt(input[i],10);
    }
    var max = 0;
    for(var i = 0;i < n;i++){
        if(max < w[i])
            max = w[i];
    }

    var left = 0;right = Math.floor(n / k) + 1;
    right *= max;

    while(right - left > 1){
        var mid = Math.floor((right + left) / 2);
        if(judge(mid))right = mid;
        else left = mid;
    }
    console.log(right);
}

Main(require("fs").readFileSync("/dev/stdin","utf8"));