#include <bits/stdc++.h>
using namespace std;
class DisjoinSet {
 public:
  vector<int> parent;
  vector<int> rank;
  DisjoinSet(int size) {
    rank.resize(size, 0);
    parent.resize(size, 0);
    for (int i = 0; i < size; i++) {
      makeSet(i);
    }
  }
  void makeSet(int x) {
    rank[x] = 0;
    parent[x] = x;
  }
  int findSet(int x) {
    if (parent[x] != x) {
      return findSet(parent[x]);
    } else {
      return x;
    }
  }
  void unite(int x, int y) { link(findSet(x), findSet(y)); }
  bool same(int x, int y) { return findSet(x) == findSet(y); }

 private:
  void link(int x, int y) {
    if (rank[x] > rank[y]) {
      parent[y] = x;
    } else {
      parent[x] = y;
      if (rank[x] == rank[y]) {
        rank[y] += 1;
      }
    }
  }
};
class Edge {
 public:
  int source, target, cost;
  Edge(int source, int target, int cost)
      : source(source), target(target), cost(cost) {}
  bool operator<(const Edge &e) const { return cost < e.cost; }
};
int Kruskal(int V, vector<Edge> edges) {
  sort(edges.begin(), edges.end());
  DisjoinSet disjoinSet = DisjoinSet(V);
  for (int i = 0; i < V; i++) {
    disjoinSet.makeSet(i);
  }
  int totalCost = 0;
  for (int i = 0; i < edges.size(); i++) {
    Edge edge = edges[i];
    if (disjoinSet.same(edge.source, edge.target) == false) {
      disjoinSet.unite(edge.source, edge.target);
      totalCost += edge.cost;
    }
  }
  return totalCost;
}
class City {
 public:
  int id, size;
  City(int id, int size) : id(id), size(size) {}
  bool operator<(const City &c) const { return size < c.size; }
};
const long long INF = 1LL << 60;
int main() {
  int N, D;
  cin >> N >> D;
  vector<City> cities;
  for (int i = 0; i < N; i++) {
    int size;
    cin >> size;
    cities.push_back(City(i, size));
  }
  sort(cities.begin(), cities.end());
  vector<Edge> edges;
  for (int i = 0; i < N; i++) {
    City source = cities[i];
    long long leftMin = INF;
    int leftMinIndex = -1;
    for (int j = i - 1; j >= 0; j--) {
      City target = cities[j];
      long long tmp =
          abs(source.id - target.id) * D + source.size + target.size;
      if (tmp < leftMin) {
        leftMin = tmp;
        leftMinIndex = target.id;
      }
    }
    if (leftMinIndex >= 0) {
      edges.push_back(Edge(source.id, leftMinIndex, leftMin));
    }
    long long rightMin = INF;
    int rightMinIndex = -1;
    for (int j = i + 1; j < N; j++) {
      City target = cities[j];
      long long tmp =
          abs(source.id - target.id) * D + source.size + target.size;
      if (tmp < leftMin) {
        rightMin = tmp;
        rightMinIndex = target.id;
      }
    }
    if (rightMinIndex >= 0) {
      edges.push_back(Edge(source.id, rightMinIndex, rightMin));
    }
  }
  cout << Kruskal(N, edges) << endl;
  return 0;
}
