#include using namespace std; typedef long long ll; const ll oo = -(1<<30); ll add(deque> &hist, ll i, ll xi) { auto it = lower_bound(hist.begin(), hist.end(), make_pair(xi, -oo)); if (it != hist.end() && it->second >= i+xi) return it->second; if (it != hist.end() && it->first == xi) it->second = i+xi; else it = hist.insert(it, make_pair(xi, i+xi)); int idx = it - hist.begin(); while (idx > 0) { --idx; if (hist[idx].second <= i+xi) hist.erase(hist.begin() + idx); else break; } return i+xi; } int main(void) { ll n, c; scanf("%lld%lld", &n, &c); deque> plus, minus; for (int i = 0; i < n; ++i) { ll x; scanf("%lld", &x); printf("%lld\n", max(add(plus, c*i, x) - x - c*i, add(minus, c*i, -x) + x - c*i)); } }