#include using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int N,K; cin >> N >> K; vectorA(N); for(int i = 0; i < N; i++) { cin >> A[i]; } int l = 0,r = 2001001001; while(l+1 < r) { int mid = ((long long)(l)+r)/2; long long sum = 0,sum2 = 0; for(int i = 0; i < N; i++) { if(sum+A[i] <= mid) { sum2 += (mid-sum-A[i]+i)/(i+1); sum += (mid-sum-A[i]+i)/(i+1)*(i+1); } } if(sum2 <= K) { l = mid; } else { r = mid; } } cout << l << endl; }