#include <bits/stdc++.h>
using namespace std;
long long n, d;
long long a[200005];
bool used[200005];
class UnionFind {
 public:
  vector<int> uni;
  UnionFind(int s) : uni(s, -1) {}
  int root(int a) {
    if (uni[a] < 0) return a;
    return uni[a] = root(uni[a]);
  }
  bool connect(int a, int b) {
    a = root(a);
    b = root(b);
    if (a == b) return false;
    if (uni[a] > uni[b]) {
      a ^= b;
      b ^= a;
      a ^= b;
    }
    uni[a] = uni[a] + uni[b];
    uni[b] = a;
    return true;
  }
  bool isConnect(int a, int b) { return root(a) == root(b); }
  int size(int a) { return -uni[root(a)]; }
};
typedef pair<int, int> pii;
int prim() {
  priority_queue<pii, vector<pii>, greater<pii> > que;
  memset(used, 0, sizeof(used));
  que.push(pii(0, 0));
  int ret = 0;
  while (!que.empty()) {
    int cst = que.top().first, v = que.top().second;
    que.pop();
    if (used[v]) continue;
    used[v] = 1;
    ret += cst;
    for (int i = 0; i < n; i++) que.push(pii(abs(i - v) * d + a[i] + a[v], i));
  }
  return ret;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n >> d;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  cout << prim() << endl;
  return 0;
}
