#include <bits/stdc++.h>
using namespace std;
int fa[5 * 200005], a[200005], n, m;
long long ans;
struct node {
  int L, R;
  long long val;
  node(int x, int y, int z) { val = x, L = y, R = z; }
  bool operator<(const node &x) const { return val < x.val; }
};
int search(int x) {
  if (fa[x] == -1) return x;
  return fa[x] = search(fa[x]);
}
vector<node> v;
void solve(int l, int r) {
  if (l == r) return;
  int mid = (l + r) >> 1, min_l, mn = -1, min_r;
  for (int i = l; i <= mid; i++) {
    if (mn == -1 || mn > a[i]) min_l = i, mn = a[i];
  }
  mn = -1;
  for (int i = mid + 1; i <= r; i++) {
    if (mn == -1 || mn > a[i]) min_r = i, mn = a[i];
    long long tmp =
        (long long)a[i] + (long long)a[min_l] + m * (long long)(i - min_l);
    v.push_back(node(tmp, min_l, i));
  }
  for (int i = l; i <= mid; i++) {
    long long tmp =
        (long long)a[i] + (long long)a[min_r] + m * (long long)(min_r - i);
    v.push_back(node(tmp, i, min_r));
  }
  solve(l, mid);
  solve(mid + 1, r);
}
int main() {
  memset(fa, -1, sizeof(fa));
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) scanf("%d", a + i);
  solve(1, n);
  sort(v.begin(), v.end());
  n--;
  for (int i = 0;; i++) {
    int x = search(v[i].L), y = search(v[i].R);
    if (x == y) continue;
    ans += v[i].val;
    n--;
    if (!n) {
      printf("%lld\n", ans);
      return 0;
    }
    fa[x] = y;
  }
}
