#include #include #include using namespace std; using ll = long long; int main(){ int n, k; cin >> n >> k; vector a(n); for(auto &it: a) cin >> it; ll ac = 0, wa = 1LL << 60; while(wa-ac > 1){ ll wj = (wa+ac)/2; ll k1 = k; ll tot = 0; for(int i = 0; i < n; i++){ if(wj <= a[i]+tot) continue; ll x = wj-(a[i]+tot); x = (x+i)/(i+1); tot += x*(i+1); k1 -= x; if(k1 < 0) break; } (k1 < 0 ? wa : ac) = wj; } cout << ac << endl; return 0; }