local n, k = io.read("*n", "*n") k = 1LL * k local a = {} for i = 1, n do a[i] = 1LL * io.read("*n") end local function solve(x) local cnt = 0LL local sum = 0LL for i = 1, n do if sum + a[i] < x then local needadd = (x - sum - a[i] + i - 1LL) / (1LL * i) cnt = cnt + needadd if k < cnt then return false end sum = sum + needadd * i end end -- print(x, cnt) return true end local min, max = 0LL, 1LL * 1000000007 * 200000 while 1LL < max - min do local mid = (min + max) / 2LL if solve(mid) then min = mid else max = mid end end min = tostring(min):gsub("LL", "") print(min)