#include<bits/stdc++.h>
#define MAX 100000
typedef long long ll;
using namespace std;
int n,k;
ll T[MAX];
int check(ll P){
	int i=0;
	for(int j=0;j<k;j++){
		ll s=0;
		while(s+T[i]<=P){
			s+=T[i];
			i++;
			if(i==n)
				return n;
		}
	}
	return i;
}
int solve(){
	ll l = 0;
	ll r = 100000 * 10000;
	ll mid;
	while(r>l+1){
		mid = (r+l)/2;
		int v = check(mid);
		if(v>=n){  //满足此式子v=n于是要缩小r的值 
			r = mid;
		}
		else{
			l = mid;
		}
	}
	return r;
}
int main(){
	cin>>n>>k;
	for(int i=0;i<n;i++){
		cin>>T[i];
	}
	ll ans = solve();
	cout<<ans<<endl;
	return 0;
} 
