#include using namespace std; const int N = 1e5 + 5; const long long INF = 1e15; int n, k; long long l, r = INF, a[N]; bool Check(long long x) { long long cnt = 0, sum = 0; for (int i = 1; i <= n; i++) { if (a[i] + sum < x) { long long j = (x - a[i] - sum + i - 1) / i; cnt += j, sum += i * j; } } return cnt <= k; } int main() { ios::sync_with_stdio(0), cin.tie(0); cin >> n >> k; for (int i = 1; i <= n; i++) { cin >> a[i]; } while (l < r) { long long mid = (l + r + 1) >> 1; Check(mid) ? l = mid : r = mid - 1; } cout << l; return 0; }