#include <iostream>
#include <algorithm>
#define endl '\n'
using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int total = 0;

    int N, S;
    cin >> N >> S;

    int P[N];
    int cP[N]; //cP are sell prices

    for (int i = 0; i < N; i++) {
        cin >> P[i];
        cP[i] = P[i];
    }
    sort(cP, cP + N);

    for (int i = 0, sM = N - 2; i < N; i++) {
        P[i] += S*sM;
        if (sM > 1) sM--;
    }
    sort(P, P + N);

    for (int i = 0; i < N; i++) {
        if (!(P[i] - cP[i] <= 0)) {
            total += P[i] - cP[i];
        }
    }

    cout << total << endl;

    return 0;
}
