N, P = map(int, input().split()) a = list(map(int, input().split())) cost = 0 inc = 0 up = 0 warp = 0 for n, m in zip(a, a[1:]): if n <= m: if inc == 0: warp += P inc = 1 up += m-n else: if inc == 1: if warp > up: warp = up warp += P print(min(up, warp))