import sys sys.setrecursionlimit(int(1e6)) input = lambda: sys.stdin.readline().rstrip("\r\n") MOD = 998244353 INF = int(4e18) if __name__ == "__main__": N, C = map(int, input().split()) H = list(map(int, input().split())) dp = [INF, 0, INF] # (jump, right, left) for h1, h2 in zip(H, H[1:]): ndp = [INF, INF, INF] ndp[0] = min(dp) + C ndp[1] = min(dp[0], dp[1]) + max(0, h2 - h1) ndp[2] = min(dp[0], dp[2]) + max(0, h1 - h2) dp = ndp print(min(dp))