#include <bits/stdc++.h>
using namespace std;
long long boxes[100000];
long long N, M;
bool can(long long t) {
  long long n = M;
  long long rest = 0;
  for (long long i = N; i >= 1; i--) {
    long long a = boxes[i - 1];
    long long d = min(a, rest);
    a -= d;
    rest -= d;
    if (a > 0) {
      long long tt = t - i;
      if (tt <= 0) return false;
      long long cnt = a / tt;
      if (a % tt != 0) cnt++;
      n -= cnt;
      rest += cnt * tt - a;
    }
  }
  return n >= 0;
}
int main() {
  cin >> N >> M;
  for (int i = 0; i < N; i++) cin >> boxes[i];
  long long minT = 1;
  long long maxT = 1000000000LL * 1000000LL;
  while (maxT - minT > 1) {
    long long t = (minT + maxT) / 2;
    if (can(t))
      maxT = t;
    else
      minT = t;
  }
  long long res = maxT;
  while (res > 1 && can(res - 1)) res--;
  cout << res << "\n";
  return 0;
}
