import java.util.Arrays; import java.util.Scanner; public class Main { public static void main(String[] args) { new Main().run(); } static void run() { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); long p = sc.nextLong(); long[] h = new long[n]; for (int i = 0; i < n; ++i) { h[i] = sc.nextLong(); } long[][] dp = new long[n][2]; for (int i = 0; i < n; ++i) { dp[i][0] = Long.MAX_VALUE / 3; dp[i][1] = Long.MAX_VALUE / 3; } dp[0][0] = 0; dp[0][1] = p; for (int i = 1; i < n; ++i) { dp[i][0] = Math.min(dp[i][0], dp[i - 1][0] + Math.max(0, h[i] - h[i - 1])); dp[i][0] = Math.min(dp[i][0], dp[i - 1][1] + Math.max(0, h[i] - h[i - 1])); dp[i][1] = Math.min(dp[i][1], dp[i - 1][0] + p); dp[i][1] = Math.min(dp[i][1], dp[i - 1][1] + p); dp[i][1] = Math.min(dp[i][1], dp[i - 1][1] + Math.max(0, h[i - 1] - h[i])); } System.out.println(Math.min(dp[n - 1][0], dp[n - 1][1])); } static void tr(Object... objects) { System.out.println(Arrays.deepToString(objects)); } }