#include<cstdio>
#include<iostream>
#include<limits>
using namespace std;
int n,m;
long long A[100005];
bool check(long long x){
int tot=0,bgin=1;
for(int i=1;i<=n;i++){
while(i<=n&&A[i]-A[bgin-1]<=x)i++;
if(A[i]-A[bgin-1]>x||i>n)tot++,bgin=i;
if(i==n)tot++;
if(tot>m)return 0;
}
return tot<=m;
}
int main(){
//cout<<numeric_limits<int>::max();
freopen("seqa.in","r",stdin);
freopen("seqa.out","w",stdout);
scanf("%d%d",&n,&m);
for(int i=1;i<=n;i++)
scanf("%lld",&A[i]),A[i]+=A[i-1];
long long l=0,r=A[n];
while(l+1<r){
long long m=(l+r)/2;
if(check(m))r=m;
else l=m;
}
printf("%lld",r);
return 0;
}