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

int N, S;
int total = 0;

void calc(int arr[], int t, int load, int index) {
    if (index == N - 1) {
        total = max(total, t);
        return;
    }
    if (load > 0) calc(arr, t + arr[index] - load*S, load - 1, index + 1);
    calc(arr, t - arr[index] - load*S, load + 1, index + 1);
    calc(arr, t - load*S, load, index + 1);
}

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

    cin >> N >> S;

    int P[N];

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

    calc(P, 0, 0, 0);

    cout << total+1 << endl;

    return 0;
}
