#include <bits/stdc++.h>
using namespace std;
FILE* in = stdin;
FILE* out = stdout;
const int MAX = 200002;
const unsigned long long INF = -1ULL;
int n;
long long d;
long long a[MAX];
struct Connection {
  int comp1, comp2;
  long long price;
  Connection(int comp1_ = -1, int comp2_ = -1, long long price_ = 0)
      : comp1(comp1_), comp2(comp2_), price(price_) {}
  bool operator<(const Connection& r) const {
    return price != r.price
               ? price > r.price
               : (comp1 != r.comp1 ? comp1 < r.comp1 : comp2 < r.comp2);
  }
};
struct Component {
  int left, right;
  long long priceLeft, priceRight;
};
int parent[MAX];
Component comp[MAX];
int getComp(int node) {
  if (parent[node] == node) return node;
  return parent[node] = getComp(parent[node]);
}
void solve() {
  for (int i = 0; i < n; i++) {
    parent[i] = i;
    comp[i].left = i;
    comp[i].right = i;
    comp[i].priceLeft = a[i];
    comp[i].priceRight = a[i];
  }
  priority_queue<Connection> q;
  for (int i = 0; i < n - 1; i++) {
    long long price = comp[i].priceRight + d + comp[i + 1].priceLeft;
    q.push(Connection(i, i + 1, price));
  }
  long long ans = 0;
  while (!q.empty()) {
    Connection conn = q.top();
    q.pop();
    int comp1 = getComp(conn.comp1);
    int comp2 = getComp(conn.comp2);
    if (comp1 == comp2) continue;
    ans += conn.price;
    parent[comp2] = comp1;
    Component& merged = comp[comp1];
    Component& other = comp[comp2];
    merged.priceLeft =
        min(merged.priceLeft,
            other.priceLeft + d * (merged.right - merged.left + 1));
    merged.priceRight =
        min(other.priceRight,
            merged.priceRight + d * (other.right - other.left + 1));
    merged.right = other.right;
    if (merged.left - 1 >= 0) {
      int lComp = getComp(merged.left - 1);
      long long price = comp[lComp].priceRight + d + merged.priceLeft;
      q.push(Connection(lComp, comp1, price));
    }
    if (merged.right + 1 < n) {
      int rComp = getComp(merged.right + 1);
      long long price = merged.priceRight + d + comp[rComp].priceLeft;
      q.push(Connection(comp1, rComp, price));
    }
  }
  fprintf(out, "%lld\n", ans);
}
int main(void) {
  while (fscanf(in, "%d", &n) == 1) {
    fscanf(in, "%lld", &d);
    for (int i = 0; i < n; i++) fscanf(in, "%lld", &a[i]);
    solve();
  }
  return 0;
}
