#include <bits/stdc++.h>
using namespace std;
const int inf = 1 << 30;
const long double eps = 1e-9;
int n, m;
int a[200000], b[200000];
bool go(long long x) {
  for (int i = 0; i < (int)n; i++) b[i] = a[i];
  long long pos = n - 1, mcur;
  long long d, mtotal = 0;
  while (pos >= 0) {
    while (pos >= 0 && !b[pos]) pos--;
    if (pos < 0) break;
    mcur = (b[pos] + x - pos - 2) / (x - pos - 1);
    d = mcur * (x - pos - 1);
    while (pos >= 0 && b[pos] <= d) {
      d -= b[pos];
      pos--;
    }
    if (pos >= 0) b[pos] -= d;
    mtotal += mcur;
  }
  return mtotal <= m;
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < (int)n; i++) scanf("%d", &a[i]);
  long long l, r = n * m;
  for (int i = n - 1; i >= 0; i--)
    if (a[i]) {
      l = i + 2;
      break;
    }
  for (int i = 0; i < (int)n; i++) r += a[i];
  long long mid;
  while (l < r) {
    mid = (l + r) >> 1;
    if (go(mid))
      r = mid;
    else
      l = mid + 1;
  }
  printf("%I64d", l);
  return 0;
}
