#include <bits/stdc++.h>
using namespace std;
long long n, m;
long long a[100100];
long long limit = 0ll;
bool C(long long x) {
  if (x <= limit) return false;
  long long res = 0ll;
  long long person = 0ll;
  for (long long i = limit - 1ll; i >= 0ll; i--) {
    long long rem = a[i];
    long long k = min(rem, res);
    rem -= k;
    res -= k;
    long long restime = x - i - 1ll;
    long long need_num = (rem == 0ll) ? 0ll : ((rem - 1ll) / restime + 1ll);
    res += need_num * restime - rem;
    person += need_num;
  }
  if (person > m)
    return false;
  else
    return true;
}
int main() {
  cin >> n >> m;
  for (long long i = 0ll; i < n; i++) {
    cin >> a[i];
    if (a[i] > 0ll) limit = i + 1ll;
  }
  long long l = 0ll, r = 10000000000000000ll;
  while (r - l > 1ll) {
    long long mid = (l + r) / 2ll;
    if (C(mid))
      r = mid;
    else
      l = mid;
  }
  cout << r << endl;
  return 0;
}
