#include <stdio.h>

#define MAX 100000
typedef long long ll;

int total,track;
ll T[MAX];

int check(ll P){
    int count = 0; //荷物を数える．
    for (int i = 0; i < track; i++){
        ll now = 0;
        while (now + T[count] <= P){
            now +=  T[count];
            count++;
            if (count == total) return total;
        }
    }
    return count;
}


int solve(){
    ll left = 0;
    ll right = 10000*100000;
    ll mid;  //最小積載量の候補
    while (right - left > 1){
        mid = (left + right) / 2;
        int v = check(mid); //どれだけ余裕があるか確認
        if(v >= total) right = mid;
        else left = mid;
    }
    return right;
}

int main(){
    ll ans= 0;
    scanf("%d%d" ,&total ,&track);
    for(int i = 0 ; i < total ; i++){
        scanf("%lld" ,&T[i]);
    }
    ans = solve();
    printf("%lld\n" ,ans);
    return 0;
}
