#include <bits/stdc++.h>
using std::cin;
using std::cout;
std::vector<int> A;
long long D;
template <size_t mK>
struct KHeap {
  struct node_t {
    int key;
    long long prio;
  };
  void RestoreDown(int index) {
    while (1) {
      for (size_t i = 0; i < mK; ++i) {
        mChild[i] =
            ((mK * index + i + 1) < mData.size()) ? (mK * index + i + 1) : -1;
      }
      auto min_prio = std::numeric_limits<long long>::max();
      int min_child_index = -1;
      for (size_t i = 0; i < mK; ++i) {
        if (mChild[i] != -1 && mData[mChild[i]].prio < min_prio) {
          min_child_index = mChild[i];
          min_prio = mData[min_child_index].prio;
        }
      }
      if (min_child_index == -1) break;
      if (mData[index].prio > mData[min_child_index].prio) {
        std::swap(mData[index], mData[min_child_index]);
      }
      index = min_child_index;
    }
  }
  void RestoreUp(int index) {
    int parent = (index - 1) / mK;
    while (parent >= 0) {
      if (mData[index].prio < mData[parent].prio) {
        std::swap(mData[index], mData[parent]);
        index = parent;
        parent = (index - 1) / mK;
      } else
        break;
    }
  }
  void Heapify() {
    for (int i = (static_cast<int>(mData.size()) - 1) / mK; i >= 0; --i) {
      RestoreDown(i);
    }
  }
  node_t ExtractMin() {
    auto min = mData[0];
    mData[0] = mData.back();
    mData.resize(mData.size() - 1);
    RestoreDown(0);
    return min;
  }
  std::array<int, mK> mChild;
  std::vector<node_t> mData;
};
int main(int argc, char* argv[]) {
  std::ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N;
  cin >> N >> D;
  A.resize(N);
  for (auto& ai : A) {
    cin >> ai;
  }
  KHeap<4> q;
  q.mData.resize(N - 1);
  for (int i = 2; i <= N; ++i) {
    long long cost = (i - 1) * D + A[0] + A[i - 1];
    q.mData[i - 2] = {i, cost};
  }
  q.Heapify();
  long long res = 0;
  while (q.mData.size()) {
    auto cur = q.ExtractMin();
    res += cur.prio;
    for (size_t i = 0; i < q.mData.size(); ++i) {
      long long ncost = std::abs(cur.key - q.mData[i].key) * D +
                        A[cur.key - 1] + A[q.mData[i].key - 1];
      if (ncost < q.mData[i].prio) {
        q.mData[i].prio = ncost;
        q.RestoreUp(i);
      }
    }
  }
  cout << res << "\n";
  return 0;
}
