#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<time.h>
#include<math.h>
int n,k,w[100000];
int check(int P)
{
	int j,i2=0;
	long long int sum;
	for(j=1;j<=k;j++)
	{
		sum=0;
		while(sum+w[i2+1]<=P)
		{
			i2++;
			sum+=w[i2];
			if(i2==n)
				return n;
		}
	}
	return i2;
}
int binarysearch(int left,int right,int minP)
{
	if(left>right)
		return minP;
	int mid;
	mid=(left+right)/2;
	int v=check(mid);
	if(v>=n)
	{
		if(minP>mid)
			minP=mid;

		binarysearch(left,mid-1,minP);
	}
	else
		binarysearch(mid+1,right,minP);
}
int main()
{
	int i,p;
	int MAX=100000*10000;
	scanf("%d %d",&n,&k);
	for(i=1;i<=n;i++)
		scanf("%d",&w[i]);
	p=binarysearch(0,MAX,MAX);
	printf("%d\n",p);
	return 0;
}
