#include #include using namespace std; int main(){ long long n,m;cin>>n>>m; vector A(n); for(int i = 0; n > i; i++){ cin>>A[i]; } long long mn = 0; long long mx = A[0]+1; while(mx-mn > 1){ long long ce = (mn+mx)/2; long long 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; }