#include <bits/stdc++.h>
using namespace std;
const int maxn = (int)1e5 + 10;
long long v[maxn];
long long t[maxn];
bool go(int n, int m, long long cnt) {
  long long need = 0;
  for (int i = 0; i < n; i++) {
    t[i] = v[i];
  }
  long long a = cnt;
  for (int i = 0; i < n; i++) {
    cnt--;
    if (t[i] % cnt == 0) {
      need += t[i] / cnt;
    } else {
      need += t[i] / cnt + 1;
      long long f = cnt - t[i] % cnt;
      for (int j = i + 1; j < n; j++) {
        f--;
        if (t[j] >= f) {
          t[j] -= f;
          break;
        } else {
          f -= t[j];
          t[j] = 0;
        }
      }
    }
  }
  if (need > m) {
    return false;
  }
  return true;
}
int main() {
  long long r = (long long)1e16;
  int n, m;
  scanf("%d %d", &n, &m);
  long long l = 1;
  for (int i = 0; i < n; i++) {
    scanf("%I64d", &v[i]);
    if (v[i] != 0) {
      l = i + 2;
    }
  }
  n = l - 1;
  while (l != r) {
    long long mid = (l + r) >> 1;
    if (go(n, m, mid)) {
      r = mid;
    } else {
      l = mid + 1;
    }
  }
  cout << l << endl;
  return 0;
}
