import sys input = sys.stdin.readline N,P=map(int,input().split()) A=list(map(int,input().split())) USE=[0]*N for i in range(1,N-1): if A[i-1]<=A[i]<=A[i+1]: USE[i]=1 if A[i-1]>=A[i]>=A[i+1]: USE[i]=1 B=[] for i in range(N): if USE[i]==0: B.append(A[i]) if len(B)>=2 and B[0]>=B[1]: B.pop(0) ANS=0 for i in range(0,len(B),2): if i+1=0: DP[i]=min(DP[i],DP[i-1]+P) if i-2>=0: DP[i]=min(DP[i],DP[i-2]+B[i-1]-B[i-2]) DP[i]=min(DP[i],DP[i-2]+P) else: if i-1>=0: DP[i]=min(DP[i],DP[i-1]+P) if i-2>=0: DP[i]=min(DP[i],DP[i-2]+B[i-2]-B[i-1]) DP[i]=min(DP[i],DP[i-2]+P) ANS=DP[-1] if len(B)>=2: ANS=min(ANS,DP[-2]+P) if len(B)>=2: if len(B)%2==0: ANS=min(ANS,DP[-2]+B[-1]-B[-2]) else: ANS=min(ANS,DP[-2]) print(ANS)