#include "bits/stdc++.h" #define rep(i,n)for(int i=0;i<(int)(n);i++) using namespace std; #define all(a) a.begin(),a.end() typedef long long ll; typedef pairP; #define vi vector const ll inf=1ll<<61; ll a[100006]; ll rwa[200005]; ll to[20][100005]; signed main(){ ll n,k;cin>>n>>k; ll S=0; rep(i,n){ cin>>a[i]; rwa[i+1]=rwa[i+n+1]=a[i]; S+=a[i]; } rep(i,n+n)rwa[i+1]+=rwa[i]; ll lb=0,ub=(S/k)+1; while(ub-lb>1){ //全員がmi以上保持できるか? ll mi=(ub+lb)/2; rep(i,n){ auto itr=lower_bound(rwa,rwa+n+n+1,rwa[i]+mi); to[0][i]=itr-rwa; to[0][i+n]=to[0][i]+n; if(to[0][i+n]>=n+n)to[0][i+n]=n+n; } to[0][n+n]=n+n; rep(i,19){ rep(j,n+n+1){ to[i+1][j]=to[i][to[i][j]]; } } int ok=0; rep(i,n){ int now=i; rep(j,19){ if(k&(1<