#include <bits/stdc++.h>
using namespace std;
const int N = int(1e5 + 5);
long long a[N];
int main() {
  int n, m;
  cin >> n >> m;
  long long sum = n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    sum += a[i];
  }
  long long l = 1, r = sum + 1;
  while (l + 1 < r) {
    long long mid = (l + r) / 2;
    long long rem = 0;
    long long workers = 0;
    for (int i = 0; i < n; i++) {
      rem = max(0LL, rem - 1);
      long long da = min(rem, a[i]);
      rem -= da;
      long long tmp = a[i];
      a[i] -= da;
      if (a[i]) {
        long long effect = mid - i - 1;
        if (effect <= 0) {
          workers = m + 1;
        } else {
          workers += (a[i] + effect - 1) / effect;
          rem = (a[i] % effect ? effect - a[i] % effect : 0);
        }
      }
      a[i] = tmp;
    }
    if (workers <= m) {
      r = mid;
    } else {
      l = mid;
    }
  }
  cout << r << endl;
  return 0;
}
