#include <bits/stdc++.h>
template <typename T1, typename T2>
inline void chmin(T1 &a, T2 b) {
  if (a > b) a = b;
}
template <typename T1, typename T2>
inline void chmax(T1 &a, T2 b) {
  if (a < b) a = b;
}
using namespace std;
class UnionFind {
  vector<int> p;

 public:
  UnionFind(int n) {
    p = vector<int>(n);
    for (int i = 0; i < n; i++) {
      p[i] = i;
    }
    return;
  }
  int find(int x) {
    if (p[x] == x) return x;
    return p[x] = find(p[x]);
  }
  void unite(int x, int y) { p[find(x)] = p[find(y)]; }
  bool same(int x, int y) { return find(x) == find(y); }
};
class Solve {
 public:
  int N;
  long long int D;
  vector<long long int> A;
  void input() {
    cin >> N >> D;
    A.resize(N);
    for (int i = int(0); i < int(N); i++) cin >> A[i];
  }
  struct edge {
    int a;
    int b;
    long long int w;
  };
  vector<edge> edges;
  void left() {
    int key = N - 1;
    long long int val = A[N - 1];
    for (int i = N - 2; i >= 0; --i) {
      val += D;
      edges.push_back(edge{key, i, val + A[i]});
      if (A[i] <= val) {
        val = A[i];
        key = i;
      }
    }
  }
  void right() {
    int key = 0;
    long long int val = A[0];
    for (int i = 1; i < N; ++i) {
      val += D;
      edges.push_back(edge{key, i, val + A[i]});
      if (A[i] <= val) {
        val = A[i];
        key = i;
      }
    }
  }
  void solve() {
    input();
    left();
    right();
    UnionFind uf(N);
    sort(begin(edges), end(edges), [](edge a, edge b) { return a.w < b.w; });
    long long int ans = 0ll;
    for (auto e : edges) {
      if (!uf.same(e.a, e.b)) {
        uf.unite(e.a, e.b);
        ans += e.w;
      }
    }
    cout << ans << endl;
  }
};
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  Solve().solve();
  return 0;
}
