#include<bits/stdc++.h>
#define ll long long
using namespace std;

int n, k, w[100010];
bool check(int p){
	int i = 0;
	for(int j = 1; j <= k; j++){
		ll s = 0;
		while(s + w[i] <= p){
			s += w[i];
			i++;
			if(i >= n) return true;
		}
	}
	return false;
}
void solve(){
	ll l = 0, r = 100000 * 100000;
	ll mid;
	while(l < r){
		mid = (l + r) / 2;
		//printf("l = %d, r = %d, mid = %d\n", l, r, mid);
		if(check(mid)) r = mid;
		else l = mid + 1;
	}
	printf("%d\n", l);
}
int main()
{
	scanf("%d%d", &n, &k);
	for(int i = 0; i < n; i++) scanf("%d", &w[i]);
	solve();
	return 0;
}
