#include using namespace std; #define rep(i,n) REP(i,0,n) #define REP(i,s,e) for(int i=(s); i<(int)(e); i++) #define repr(i, n) REPR(i, n, 0) #define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--) #define all(r) r.begin(),r.end() #define rall(r) r.rbegin(),r.rend() typedef long long ll; typedef vector vi; typedef vector vl; const ll INF = 1e18; const ll MOD = 1e9 + 7; template T chmax(T& a, const T& b){return a = (a > b ? a : b);} template T chmin(T& a, const T& b){return a = (a < b ? a : b);} int main(){ ll n, p; cin >> n >> p; vl h(n); rep(i, n) cin >> h[i]; vl left(n); iota(all(left), 0); REP(i, 1, n) if(h[i-1] <= h[i]) left[i] = left[i-1]; vl dp(n, INF); dp[0] = 0LL; REP(i, 1, n) { chmin(dp[i], dp[i-1]+max(0LL, h[i]- h[i-1])); { int j = (left[i] == 0 ? 0 : left[i]-1); chmin(dp[i], dp[j]+p); } } cout << dp.back() << '\n'; return 0; }