(function(input) {
    console.info = function(){};

    var p = input.split('\n');
    var args = p.shift().split(' ').map(Number);
    var n = args[0];
    var k = args[1];
    var w = p.slice(0, n).map(Number);

    var sumWeight = w.reduce(function(a, b) { return a + b; });
    var P = Math.ceil(sumWeight / k);
    //console.info(w);return;
    var add = 0;
    while (1) {
        var weights = [].concat(w);
        var M = P * k - sumWeight;
        console.info('P = ' + P);
        console.info('k = ' + k);
        console.info('sum weight = ' + sumWeight);
        console.info('M = ' + M);
        for (var i = 0; i < k; i++) {
            console.info('##kIndex = ' + i);
            var kWeight = 0;
            for (var j = 0; j < weights.length; j++) {
                console.info('####current weight = ' + weights[j]);
                if (kWeight + weights[j] <= P) {
                    console.info('######put weight = ' + weights[j]);
                    kWeight+= weights[j];
                    //weights = weights.slice(0, j).concat(weights.slice(j + 1, weights.length));
                    //j--;
                } else {
                    weights = weights.slice(j, weights.length);
                    break;
                }
                if (j == weights.length - 1) {
                    weights = [];
                }
            }
            M -= (P - kWeight);
            console.info('##kWeight = ' + kWeight);
            console.info('##current M = ' + M);
            if (M < 0) {
                break;
            }
        }
        console.info('');
        console.info('M = ' + M);
        console.info('weight leng = ' + weights.length);
        if (M >= 0 && weights.length == 0) {
            console.info('ok');
            console.info('P = ' + P);
            console.log(P);
            break;
        }
        console.info('NG');
        console.info('####################');
        P++;
    }
})(require('fs').readFileSync('/dev/stdin', 'utf8'));