#include using namespace std; using LL = long long; const int N = 1e5 + 5; LL c[N], ok, sum, a[N], now, n, k, l, r, mid, ans; LL lowbit(LL x){ return x & -x; } LL getsum(LL x){ for(ans = 0; x > 0; ans += c[x], x -= lowbit(x)){ } return ans; } void updata(int i, LL k){ for(; i <= n; c[i] += k, i += lowbit(i)){ } } bool C(LL x){ for(int i = 1; i <= n; ++i){ c[i] = 0; } for(int i = 1; i <= n; ++i){ //updata(i, a[i] - a[i - 1]); } sum = ans = 0; for(int i = 1; i <= n; ++i){ //now = getsum(i); ok = max(0ll, (x - (a[i] + ans) + i - 1) / i); sum += ok; ans += ok * i; } return sum <= k; } int main(){ cin >> n >> k; for(int i = 1; i <= n; ++i){ cin >> a[i]; } l = 0, r = (LL)(2e14); while(l < r){ mid = (l + r + 1) >> 1; if(C(mid)){ l = mid; } else{ r = mid - 1; } } cout << l; return 0; }