w[100000],c,n,k,g,i,l,m,r=1e9;
f(p){for(c=1,g=0,i=0;i<n;){if(g+w[i]<=p){g+=w[i++];}else{if(g>0)c++;else return k+1;g=0;}}return c;}
main(){for(scanf("%d%d",&n,&k);i<n;scanf("%d",w+i++));
while(l<r){m=(l+r)/2;if(f(m)>k)l=m+1;else r=m;}for(m--;;m++){if(f(m)<=k)break;}printf("%d\n",m);exit(0);}