#include #include #include #include #include #include #include #include #include #include #define mkp make_pair #define mkt make_tuple #define rep(i,n) for(int i = 0; i < (n); ++i) #define all(v) v.begin(),v.end() using namespace std; typedef long long ll; const ll MOD=1e9+7; template void chmin(T &a,const T &b){if(a>b) a=b;} template void chmax(T &a,const T &b){if(a A; const ll INF=1e15; vector sum; int to[200020][20]; bool judge(ll lim){ int M=A.size(); rep(i,M) rep(j,20) to[i][j]=M; int pos=0; for(int i=0;isum[pos]) pos++; to[i][0]=pos; } for(int k=1;k<20;k++) for(int i=0;iN) break; } if(now-i<=N) return true; } return false; } int main(){ cin.tie(0); ios::sync_with_stdio(false); cin>>N>>K; A.resize(N); rep(i,N) cin>>A[i]; rep(i,N) A.push_back(A[i]); A.push_back(INF); int M=A.size(); sum.resize(M+1,0); rep(i,M) sum[i+1]=sum[i]+A[i]; ll ok=*min_element(all(A)); ll ng=sum[N]+10; while(abs(ok-ng)>1){ ll mid=(ok+ng)/2; if(judge(mid)) ok=mid; else ng=mid; } cout<