#include using namespace std; long long a[100005], f[100005], b[100005]; long long n, k; bool C(long long x){ for(long long i = 1; i <= n; i++){ b[i] = a[i]; } long long sum = 0, ans = 0; for(long long i = 1; i <= n; i++){ if(b[i] + sum <= x){ long long u = ceil(1.0 * (x - b[i] - sum) / i); ans += u; sum += u * i; } } if(ans <= k){ return 1; } return 0; } int main(){ cin >> n >> k; for(long long i = 1; i <= n; i++){ cin >> a[i]; } long long l = 0, r = 1e15; while(l < r){ long long mid = (l + r + 1) >> 1; if(C(mid)){ l = mid; } else{ r = mid - 1; } } cout << l; return 0; }