#include <bits/stdc++.h>
using namespace std;
static bool linked[200000];
static int n;
static int64_t d;
static std::vector<int> as;
struct link_t {
  int64_t cost;
  int from;
  int to;
};
link_t getCheapestLinkToUnlinked(int from) {
  link_t ret{};
  ret.from = from;
  ret.cost = INT64_MAX;
  for (int to = 0; to < n; ++to) {
    if (linked[to]) {
      continue;
    }
    if (to == from) {
      continue;
    }
    int64_t const cost = int64_t(abs(from - to)) * d + as[from] + as[to];
    if (cost < ret.cost) {
      ret.cost = cost;
      ret.to = to;
    }
  }
  return ret;
}
int64_t solve() {
  linked[0] = true;
  std::vector<link_t> links{};
  links.push_back(getCheapestLinkToUnlinked(0));
  int64_t ret = 0;
  while (true) {
    std::sort(links.begin(), links.end(),
              [](const link_t& lhs, const link_t& rhs) {
                return lhs.cost < rhs.cost;
              });
    auto cheapestLink = links.front();
    ret += cheapestLink.cost;
    int const to = cheapestLink.to;
    linked[to] = true;
    links.push_back(getCheapestLinkToUnlinked(to));
    if (links.size() >= n) {
      break;
    }
    for (auto& link : links) {
      if (link.to != to) {
        continue;
      }
      link = getCheapestLinkToUnlinked(link.from);
    }
  }
  return ret;
}
int main() {
  std::cin.tie(nullptr);
  std::ios::sync_with_stdio(false);
  std::cin >> n >> d;
  as.resize(n);
  for (auto& a : as) {
    std::cin >> a;
  }
  std::cout << solve() << std::endl;
  return 0;
}
