#include<cstdio> using namespace std; #define N 100001 int n,m,a[N]; bool check(int x) { int now=0,sum=1; for(int i=1;i<=n;++i) { if(now+a[i]<=x) now+=a[i]; else { now=a[i]; ++sum; if(now>x||sum>m) return 0; } } return 1; } int main() { scanf("%d%d",&n,&m); for(int i=1;i<=n;++i) scanf("%d",&a[i]); int l=1,r=1000000000; while(r>l) { int mid=(l+r>>1); if(check(mid)) r=mid; else l=mid+1; } printf("%d ",l); return 0; }