#include <bits/stdc++.h>
template <class T>
using vv = std::vector<std::vector<T> >;
template <typename T>
std::ostream& operator<<(std::ostream& s, const std::vector<T>& v) {
  int len = v.size();
  s << "\n";
  for (int(i) = (0); (i) < (len); ++(i)) {
    s << v[i];
    if (i < len - 1) {
      s << "\t";
    }
  }
  s << "\n";
  return s;
}
template <typename T>
std::ostream& operator<<(std::ostream& s,
                         const std::vector<std::vector<T> >& vv) {
  int len = vv.size();
  for (int(i) = (0); (i) < (len); ++(i)) {
    s << vv[i];
  }
  return s;
}
template <typename T>
std::ostream& operator<<(std::ostream& s, const std::deque<T>& v) {
  int len = v.size();
  s << "\n";
  for (int(i) = (0); (i) < (len); ++(i)) {
    s << v[i];
    if (i < len - 1) {
      s << "\t";
    }
  }
  s << "\n";
  return s;
}
template <typename T>
std::ostream& operator<<(std::ostream& s,
                         const std::deque<std::deque<T> >& vv) {
  int len = vv.size();
  for (int(i) = (0); (i) < (len); ++(i)) {
    s << vv[i];
  }
  return s;
}
template <typename T>
std::ostream& operator<<(std::ostream& s, const std::set<T>& v) {
  s << "\n";
  for (auto elm : v) {
    s << elm << "\t";
  }
  s << "\n";
  return s;
}
inline void scan(int& a) { scanf("%d", &a); }
inline void scan(int& a, int& b) { scanf("%d%d", &a, &b); }
inline void scan(int& a, int& b, int& c) { scanf("%d%d%d", &a, &b, &c); }
inline void scan(int& a, int& b, int& c, int& d) {
  scanf("%d%d%d%d", &a, &b, &c, &d);
}
inline void scan(std::vector<int>& v) {
  int sz = v.size();
  for (int(i) = (0); (i) < (sz); ++(i)) {
    scan(v[i]);
  }
}
inline void scan(std::vector<std::vector<int> >& v) {
  int sz = v.size();
  for (int(i) = (0); (i) < (sz); ++(i)) {
    scan(v[i]);
  }
}
inline void scan(long long& a) { scanf("%lld", &a); }
inline void scan(long long& a, long long& b) { scanf("%lld%lld", &a, &b); }
inline void scan(long long& a, long long& b, long long& c) {
  scanf("%lld%lld%lld", &a, &b, &c);
}
inline void scan(long long& a, long long& b, long long& c, long long& d) {
  scanf("%lld%lld%lld%lld", &a, &b, &c, &d);
}
inline void scan(std::vector<long long>& v) {
  int sz = v.size();
  for (int(i) = (0); (i) < (sz); ++(i)) {
    scan(v[i]);
  }
}
inline void scan(std::vector<std::vector<long long> >& v) {
  int sz = v.size();
  for (int(i) = (0); (i) < (sz); ++(i)) {
    scan(v[i]);
  }
}
inline void scan(char& a) { scanf(" %c", &a); }
inline void scan(std::vector<char>& v) {
  int sz = v.size();
  for (int(i) = (0); (i) < (sz); ++(i)) {
    scan(v[i]);
  }
}
inline void scan(std::vector<std::vector<char> >& v) {
  int sz = v.size();
  for (int(i) = (0); (i) < (sz); ++(i)) {
    scan(v[i]);
  }
}
inline void scan(std::string& s) {
  char BUF[3000000];
  scanf(" %s", BUF);
  s = std::string(BUF);
}
inline void print(int a) { printf("%d\n", a); }
inline void print(int a, int b) { printf("%d %d\n", a, b); }
inline void print(long long a) { printf("%lld\n", a); }
inline void print(long long a, long long b) { printf("%lld %lld\n", a, b); }
inline void print(std::string s) { std::cout << s << "\n"; }
inline void print_yn(bool flg) {
  if (flg) {
    printf("Yes\n");
  } else {
    printf("No\n");
  }
}
using namespace std;
class UF {
 private:
  vector<int> data;
  vector<int> next;
  vector<int> last;
  void init(int n) {
    data.assign(n, -1);
    next.assign(n, -1);
    last.resize(n);
    for (int i = 0; i < n; ++i) {
      last[i] = i;
    }
  }

 public:
  UF() {}
  UF(int n) { init(n); }
  int root(int x) {
    if (data[x] < 0) return x;
    return data[x] = root(data[x]);
  }
  bool unite(int x, int y) {
    x = root(x);
    y = root(y);
    if (x == y) return false;
    if (data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    next[last[x]] = y;
    last[x] = last[y];
    return true;
  }
  int size(int x) { return -data[root(x)]; }
  bool same(int x, int y) { return root(x) == root(y); }
  int get_next(int x) { return next[x]; }
};
int main() {
  long long n, d;
  scan(n, d);
  std::vector<long long> a(n);
  scan(a);
  std::vector<int> lowest_left(n, 0);
  for (int(i) = (1); (i) < (n); ++(i)) {
    long long cur_cost = a[lowest_left[i - 1]] + d * (i - lowest_left[i - 1]);
    long long new_cost = a[i];
    if (cur_cost < new_cost) {
      lowest_left[i] = lowest_left[i - 1];
    } else {
      lowest_left[i] = i;
    }
  }
  std::vector<int> lowest_right(n, n - 1);
  for (int i = n - 2; i >= 0; --i) {
    long long cur_cost = a[lowest_right[i + 1]] + d * (lowest_right[i + 1] - i);
    long long new_cost = a[i];
    if (cur_cost < new_cost) {
      lowest_right[i] = lowest_right[i + 1];
    } else {
      lowest_right[i] = i;
    }
  }
  long long INF = LLONG_MAX / 2;
  std::vector<int> nearest(n, -1);
  for (int(i) = (0); (i) < (n); ++(i)) {
    int left_node = -1;
    int right_node = -1;
    long long left_cost = INF;
    long long right_cost = INF;
    if (i != 0) {
      left_node = lowest_left[i - 1];
      left_cost = a[i] + a[left_node] + d * (i - left_node);
    }
    if (i != n - 1) {
      right_node = lowest_right[i + 1];
      right_cost = a[i] + a[right_node] + d * (right_node - i);
    }
    if (left_cost < right_cost) {
      nearest[i] = left_node;
    } else {
      nearest[i] = right_node;
    }
  }
  std::vector<std::vector<long long> > edges;
  for (int(i) = (0); (i) < (n); ++(i)) {
    int u = i;
    int v = nearest[i];
    assert(u != v);
    if (u > v) {
      swap(u, v);
    }
    long long cost = a[u] + a[v] + d * (v - u);
    edges.push_back({cost, u, v});
  }
  for (int(i) = (0); (i) < (n - 1); ++(i)) {
    int u = nearest[i];
    int v = nearest[i + 1];
    if (u == v) {
      continue;
    }
    if (u > v) {
      swap(u, v);
    }
    long long cost = a[u] + a[v] + d * (v - u);
    edges.push_back({cost, u, v});
  }
  sort(begin(edges), end(edges));
  UF uf(n);
  long long ans = 0;
  for (auto&& edge : edges) {
    if (uf.same(edge[1], edge[2])) {
      continue;
    }
    uf.unite(edge[1], edge[2]);
    ans += edge[0];
  }
  print(ans);
  return 0;
}
