#include <bits/stdc++.h>
using namespace std;
void deba(int* a, int n) {
  cerr << "| ";
  for (int i = 0; i < (n); i++) cerr << a[i] << " ";
  cerr << "|" << endl;
}
inline bool EQ(double a, double b) { return fabs(a - b) < 1e-9; }
const int INF = 1 << 30;
int a[123456];
int n, m;
bool ok(long long sek) {
  long long k = m;
  long long zv = 0;
  for (int i = (n - 1); i >= (0); i--) {
    long long ai = a[i];
    if (ai == 0) continue;
    long long s = sek - (i + 1);
    if (s <= 0) return false;
    if (ai > zv) {
      ai -= zv;
      zv = 0;
    } else {
      zv = zv - ai;
      continue;
    }
    int km = (ai + (s - 1)) / s;
    zv = ai % s == 0 ? 0 : s - ai % s;
    k -= km;
    if (k < 0) return false;
  }
  cerr << ">>> " << ("1") << " -> " << (1) << endl;
  ;
  return true;
}
int main() {
  scanf("%d %d", &n, &m);
  ;
  for (int i = 0; i < (n); i++) scanf("%d", &a[i]);
  ;
  long long p, u = 10000000000000000LL, d = 1;
  while (u > d + 1) {
    p = (u + d) / 2;
    if (ok(p))
      u = p;
    else
      d = p;
  }
  if (ok(d)) u = d;
  cout << u << endl;
  return 0;
}
