#include <iostream>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;

int cnt(int p, int n, int k, int w[]){
    int wi = 0;
    rep(i, k){
        int ts = 0;
        while(ts + w[wi] <= p){
            ts += w[wi];
            wi++;
            if(wi == n) return n;
        }
    }
    return wi;
}

int main(){
    int n, k; cin >> n >> k;
    int w[n];
    rep(i, n) cin >> w[i];

    int l = 0;
    int r = 20000*n/k;
    while(r - l > 1){
        int p = (l + r)/2;
        int v = cnt(p, n, k, w);
        if(v >= n) r = p;
        else l = p;
    }
    cout << r << endl;
    return 0;
}
