using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		long Inf = (long) 1e16;
		int[] R = new int[N];
		R[N-1] = N-1;
		for(int i=N-2;i>=0;i--){
			if(A[i+1] >= A[i]){
				R[i] = R[i+1];
			} else {
				R[i] = i;
			}
		}
		
		long[][] dp = new long[2][];
		for(int i=0;i<2;i++){
			dp[i] = new long[N];
			for(int j=0;j<N;j++) dp[i][j] = Inf;
		}
		dp[0][0] = 0;
		
		for(int i=0;i<N-1;i++){
			dp[0][i+1] = Math.Min(dp[0][i+1],dp[0][i] + Math.Max(0,A[i+1] - A[i]));
			if(R[i] != i){
				if(R[i] == i+1){
					dp[0][i+1] = Math.Min(dp[0][i+1],dp[0][i] + P);
				} else {
					dp[1][R[i]] = Math.Min(dp[1][R[i]], dp[0][i] + P);
				}
			}
			
			dp[0][i+1] = Math.Min(dp[0][i+1],dp[1][i] + P);
			dp[1][R[i+1]] = Math.Min(dp[1][R[i+1]],dp[1][i] + P);
		}
		
		Console.WriteLine(Math.Min(dp[0][N-1],dp[1][N-1]));
	}
	int N;
	long P;
	long[] A;
	public Sol(){
		var d = ria();
		N = d[0]; P = d[1];
		A = rla();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}