#include<iostream>
#include<algorithm>
using namespace std;
const int N=1e5+10;
int a[N];
int n,k;
bool binary(int x){
int cut=0,i;
for(i=0;i<n;){
int res=0;
cut++;
while(res<x){
res+=a[i];
i++;
if(i>=n)break;
}
}
if(cut>=k)return true;
else return false;
}
int main(){
int shortest=1e9;
int r=0;
scanf("%d %d",&n,&k);
for(int i=0;i<n;i++) {
scanf("%d", &a[i]);
shortest = min(shortest, a[i]);
r += a[i];
}
int l=shortest-1;r=r+1;
while(l+1!=r){
int mid=(l+r)/2;
if(binary(mid))l=mid;
else r=mid;
}
cout<<l;
return 0;
}