#include <bits/stdc++.h>
using namespace std;
long long a[200005], sum, b[200005];
long long n, m;
bool check(long long mid) {
  for (int i = n; i >= 1; i--) {
    b[i] = a[i];
  }
  b[0] = 0;
  for (int i = n; i >= 1; i--) {
    long long t = ceil(b[i] * 1.0 / m);
    b[i - 1] =
        (((0ll) > (b[i - 1] - (t * m - b[i]))) ? (0ll)
                                               : (b[i - 1] - (t * m - b[i])));
    mid -= t;
    if (mid < 0) {
      return false;
    }
  }
  return true;
}
int main() {
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    scanf("%lld", &a[i]);
  }
  long long l = 0, r = 2e14, ans = -1;
  while (r >= l) {
    long long mid = (l + r) / 2;
    if (check(mid)) {
      ans = mid;
      r = mid - 1;
    } else {
      l = mid + 1;
    }
  }
  printf("%lld\n", ans);
}
