#include long long int a[200005]; int main() { long long int n, m; scanf("%lld %lld", &n, &m); long long int i; for (i = 0; i < n; i++) scanf("%lld", &a[i]); long long int min, mid, max; min = -1; max = 1e9; long long int cnt, f; while (max - min > 1) { mid = (max + min) / 2; cnt = f = 0; for (i = 0; i < n; i++) { if (a[i] + cnt < mid * m) f++; else cnt = a[i] + cnt - mid * m; } if (f > 0) max = mid; else min = mid; } printf("%lld\n", min); return 0; }