#include<iostream>
#include<cstring>
using namespace std;
const int MAX = 1e5+6;
const int INF = 0x7fffffff;
typedef long long int llint;
int N,group;
llint a[MAX];
inline bool judge_l(llint mid)
{
int total=0;
llint sum=mid;
for(int pre=1,next=2;next<=N+1;pre++,next++)
{
if(a[pre]<=sum and a[next]>sum)
{
sum=a[pre];
sum+=mid;
total++;
}
else if(a[pre]>sum)
{
return true;
}
}
return total>group;
}
int main()
{
freopen("../IO/P1182_5.in","r",stdin);
cin>>N>>group;
for(int i=1;i<=N;i++)
{
llint tmp;
cin>>tmp;
a[i]=a[i-1]+tmp;
}
a[N+1]=INF;
llint l=1,r=a[N];
while(l<r)
{
llint m=(l+r)/2;
if(judge_l(m))
{
l=m+1;
}
else
{
r=m;
}
}
cout<<l<<endl;
fclose(stdin);
return 0;
}