#include <bits/stdc++.h>
using namespace std;
struct Fast {
  Fast() {
    std::cin.tie(0);
    ios::sync_with_stdio(false);
  }
} fast;
using ll = long long;
using ull = unsigned long long;
using vi = vector<long long>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vd = vector<double>;
using vvd = vector<vd>;
using vvvd = vector<vvd>;
using pii = pair<long long, long long>;
using vpii = vector<pii>;
using mii = map<long long, long long>;
using vs = vector<string>;
using vb = vector<bool>;
template <typename T>
using PQ = priority_queue<T>;
template <typename T>
using minPQ = priority_queue<T, vector<T>, greater<T>>;
template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (auto &v : vec) is >> v;
  return is;
}
template <typename T>
istream &operator>>(istream &is, pair<T, T> &p) {
  long long a, b;
  is >> a >> b;
  p = make_pair(a, b);
  return is;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  os << "[";
  for (auto v : vec) os << v << ",";
  os << "]";
  return os;
}
template <typename T>
ostream &operator<<(ostream &os, const deque<T> &vec) {
  os << "deq[";
  for (auto v : vec) os << v << ",";
  os << "]";
  return os;
}
template <typename T>
ostream &operator<<(ostream &os, const set<T> &vec) {
  os << "{";
  for (auto v : vec) os << v << ",";
  os << "}";
  return os;
}
template <typename T>
ostream &operator<<(ostream &os, const multiset<T> &vec) {
  os << "{";
  for (auto v : vec) os << v << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &pa) {
  os << "(" << pa.first << "," << pa.second << ")";
  return os;
}
template <typename TK, typename TV>
ostream &operator<<(ostream &os, const map<TK, TV> &make_pair) {
  os << "{";
  for (auto v : make_pair) os << v.first << "=>" << v.second << ",";
  os << "}";
  return os;
}
const ll INF = 1001001001001001001ll;
const long long MOD = 1e9 + 7;
inline bool inside(long long y, long long x, long long H, long long W) {
  return y >= 0 && x >= 0 && y < H && x < W;
}
inline bool odd(long long x) { return x % 2 == 1; }
inline bool even(long long x) { return x % 2 == 0; }
inline long long sum(vi a) { return accumulate(begin(a), end(a), 0); }
inline void yn(bool ans) { cout << (ans ? "Yes" : "No") << endl; }
inline void YN(bool ans) { cout << (ans ? "YES" : "NO") << endl; }
inline void ANS(long long ans) { cout << ans << endl; }
template <typename T>
inline bool chmin(T &a, const T &b) {
  if (a > b) a = b;
  return a > b;
}
template <typename T>
inline bool chmax(T &a, const T &b) {
  if (a < b) a = b;
  return a < b;
}
template <class T>
T gcd(const T &a, const T &b) {
  return a < b ? gcd(b, a) : b ? gcd(b, a % b) : a;
}
template <class T>
T lcm(const T &a, const T &b) {
  return a / gcd(a, b) * b;
}
template <class T>
T div_ceil(const T &a, const T &b) {
  return (a + b - 1) / b;
}
template <class T>
bool by_snd(const T &a, const T &b) {
  return a.second < b.second;
}
inline void print_and_exit(long long x) {
  cout << x << endl;
  exit(0);
}
const long long dx[] = {0, 1, 0, -1, 1, -1, 1, -1},
                dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
inline void pp2d(vvi a) {
  for (auto v : a) {
    cout << v << endl;
  }
  cout << "---\n";
}
struct UnionFind {
  vector<long long> par;
  vector<long long> sizes;
  UnionFind(long long n) : par(n), sizes(n, 1) {
    for (long long i = (0); i < (n); i++) par[i] = i;
  }
  long long find(long long x) {
    if (x == par[x]) return x;
    return par[x] = find(par[x]);
  }
  void unite(long long x, long long y) {
    x = find(x);
    y = find(y);
    if (x == y) return;
    if (sizes[x] < sizes[y]) swap(x, y);
    par[y] = x;
    sizes[x] += sizes[y];
  }
  bool same(long long x, long long y) { return find(x) == find(y); }
  long long size(long long x) { return sizes[find(x)]; }
};
struct Edge {
  long long a, b, cost;
  bool operator<(const Edge &o) const { return cost < o.cost; }
};
ostream &operator<<(ostream &os, const Edge &e) {
  os << "{ a=" << e.a << ",b=" << e.b << ",cost=" << e.cost << " }" << endl;
  return os;
}
struct Graph {
  long long n;
  vector<Edge> es;
  Graph(long long n) : n(n) {}
  long long kruskal() {
    sort(es.begin(), es.end());
    UnionFind uf(n);
    long long min_cost = 0;
    for (long long ei = (0); ei < (es.size()); ei++) {
      Edge &e = es[ei];
      if (!uf.same(e.a, e.b)) {
        min_cost += e.cost;
        uf.unite(e.a, e.b);
      }
    }
    return min_cost;
  }
};
signed main() {
  long long n, d;
  cin >> n >> d;
  ;
  vi a(n);
  cin >> a;
  Graph g(n);
  for (long long i = (0); i < (n - 1); i++)
    for (long long j = (i + 1); j < (n); j++) {
      Edge e = {i, j, abs(i - j) * d + a[i] + a[j]};
      g.es.push_back(e);
    }
  long long ans = g.kruskal();
  ANS(ans);
}
