#include #include using namespace std; int main(){ int n,m;cin>>n>>m; vector A(n); for(int i = 0; n > i; i++){ cin>>A[i]; } int mn = 0; int mx = A[0]+1; while(mx-mn > 1){ int ce = (mn+mx)/2; int nw = 0; bool ok = true; for(int i = 0; n > i; i++){ if(A[i]+nw < ce){ ok = false; break; } nw = A[i]+nw-ce; } if(ok){ mn = ce; }else{ mx = ce; } } cout << mn/m << endl; }