#include<stdio.h>

int check(int p,int n,int k,int T[])
{
	int i=0;
	for(int j=0;j<k; j++)
	{
		int s = 0;
		while(s +T[i] <= p)
		{
			s +=T[i];
			i++;
			if(i == n)
			{
				break;
			}
		}
	}
	return i;
}

int main()
{
	int n,k,i;
	scanf("%d %d",&n,&k);
	int T[n];
	
	for(i =0;i<n;i++)
	{
		scanf("%d",&T[i]);
	}
	
	int right = 100000 * 10000, left = 0, mid;
	
	while( right - left >1)
	{
		mid = (right+left)/2;
		int maxT = check(mid,n,k,T);
		if(maxT>=n)
		{
			right = mid;
		}
		else
		{
			left = mid;
		}
	}
	
	printf("%d\n", right);
	
	return 0;
}
		
	
