#include using namespace std; using ll = long long; int main(){ ios::sync_with_stdio(false); cin.tie(0); ll n, k, INF = 1ll << 61; cin >> n >> k; vector a(n); for(auto &&v:a)cin >> v; ll ok = 0, ng = 1ll << 60, mid; while(ok + 1 < ng){ mid = (ok + ng) / 2; ll cnt = 0, s = 0; for(int i = 0; i < n; i++){ if(a[i] + s < mid){ ll d = i + 1, di = mid - (a[i] + s); cnt = min(INF, cnt + (di + d - 1) / d); s = min(INF, s + (di + d - 1) / d * d); } } if(cnt <= k) ok = mid; else ng = mid; } cout << ok << '\n'; }