#include using namespace std; using LL = long long; int main() { ios_base::sync_with_stdio(false); int n, k; cin >> n >> k; vector a(n); for (LL &x : a) cin >> x; auto check = [&](LL s) { LL sum = 0, w; int cnt = 0; for (int i = 0; i < n; i++) { if (a[i] + sum < s) { w = (s - a[i] - sum + i) / (i + 1); if (cnt + w > k) return false; sum += w * (i + 1), cnt += w; } } return true; }; LL l, r, mid, res; l = 0, r = 1E18; while (l <= r) { mid = l + r >> 1; if (check(mid)) { l = (res = mid) + 1; } else { r = mid - 1; } } cout << res; return 0; }