#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e18;
long long v[100005];
long long n, m, mid;
long long tp(long long mid) {
  long long p, q;
  q = m;
  while (!v[q]) {
    q--;
  }
  p = v[q];
  for (long long a = 1; a <= n; a++) {
    long long k = mid;
    k -= q;
    if (k <= 0) {
      return 0;
    }
    while (k) {
      if (k >= p) {
        k -= p;
        q--;
        while (!v[q]) q--;
        if (q < 1) {
          return 1;
        }
        p = v[q];
      } else {
        p -= k;
        break;
      }
    }
  }
  return 0;
}
int main() {
  scanf("%lld%lld", &m, &n);
  for (long long a = 1; a <= m; a++) {
    scanf("%lld", &v[a]);
  }
  long long r = 1, l = inf;
  while (r < l) {
    mid = (r + l) / 2;
    if (!tp(mid))
      r = mid + 1;
    else {
      l = mid;
    }
  }
  printf("%lld\n", l);
  return 0;
}
