#!/usr/bin/ python3.8 import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines N, P, *H = map(int, read().split()) # 最後の 2 地点間ごとの値。jump, right, left INF = 10 ** 18 dp = [INF, 0, INF] for h1, h2 in zip(H, H[1:]): newdp = [INF, INF, INF] newdp[0] = min(dp) + P newdp[1] = min(dp[0], dp[1]) + max(0, h2 - h1) newdp[2] = min(dp[0], dp[2]) + max(0, h1 - h2) dp = newdp print(min(dp))