#include <bits/stdc++.h>
using namespace std;
const int N = 100007;
int a[N], n, m;
bool check(long long x) {
  long long tmp = 0, cnt = 0;
  for (int i = 1; i <= n; ++i) {
    cnt += (a[i] + tmp) / (x - i);
    tmp = (a[i] + tmp) % (x - i);
    if (cnt > m) return false;
  }
  if (tmp) ++cnt;
  if (cnt > m) return false;
  return true;
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; ++i) scanf("%d", a + i);
  while (a[n] == 0 && n >= 1) --n;
  long long l = n + 1, r = 1e15, mid;
  while (l <= r) {
    mid = (l + r) / 2;
    if (check(mid))
      r = mid - 1;
    else
      l = mid + 1;
  }
  cout << l << endl;
  return 0;
}
