#include<stdio.h>
#include<string.h>

#define MAX 100000
int T[MAX];
int n, k, p;

int solve();
int check(long long p);

int main(){
	int i = 0;
	long long ans;

	scanf("%d %d", &n,&k);

	for (i = 0; i < n; i++){
		scanf("%d", &T[i]);
	}

	ans = solve();
	printf("%ld", ans);

	return 0;


}

int solve(){
	long long left = 0;
	long long right = 10000 * 100000;
	long long mid;

	while (right - left > 1){
		mid = (left + right) / 2;
		int v = check(mid);
		if (v >= n)right = mid;
		else left = mid;
	}

	return right;

}

int check(long long p){
	long long sum = 0;
	int i = 0;
	int j;

	for (j = 0; j < k; j++){
		sum = 0;
		while (sum + T[i] <= p){
			sum += T[i];
			i++;
			if (i == n) return n;
		}
	}
	return i;

}