#include<iostream>
#include<vector>
using namespace std;

vector<int> a;
int n, k;

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

int getMinP()
{
	int low = 0, high = 100000 * 10000, mid;
	while(low <= high)
	{
		mid = (low + high) / 2;
		int t = check(mid);//当p=mid时候，看看怎么样
		if(t >= n)
			high = mid - 1;
		else
			low = mid + 1;
	}
	return low;
}

int main()
{
	int tmp;
	
	cin>>n>>k;
	for(int i = 0; i < n; i++)
	{
		cin>>tmp;
		a.push_back(tmp);
	}
	cout<<getMinP()<<endl;
}
