#include <bits/stdc++.h>
using namespace std;
const int N = 100005;
int n, m, a[N];
int check(long long t) {
  int cnt = m;
  long long canmove = 0;
  for (int i = n; i >= 1; --i) {
    while (canmove < a[i]) {
      canmove += t - i;
      if (--cnt < 0) return 0;
    }
    canmove -= a[i];
  }
  return 1;
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; ++i) {
    scanf("%d", a + i);
  }
  long long l = 0, r = 1LL << 60, res;
  while (l <= r) {
    long long mid = (l + r) / 2;
    if (check(mid)) {
      res = mid;
      r = mid - 1;
    } else
      l = mid + 1;
  }
  printf("%I64d\n", res);
  return 0;
}
