#include using namespace std; using i64 = long long; const int N = 1e5 + 10; int n, k; i64 a[N]; bool check(i64 m) { i64 tot = 0; int rk = k; for(int i = 1; i <= n; i ++) { if(tot + a[i] >= m) continue; if((m - tot - a[i] + i - 1) / i > rk) return false; rk -= (m - tot - a[i] + i - 1) / i; tot += ((m - tot - a[i] + i - 1) / i) * i; } return true; } int main() { cin >> n >> k; for(int i = 1; i <= n; i ++) cin >> a[i]; i64 l = 0, r = 3e14; while(l + 1 < r) { i64 mid = (l + r) / 2; if(check(mid)) l = mid; else r = mid; } cout << l; }