#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#define int long long
#define mod 1000000007
#define for0(i, n) for(int i = 0; i < (n); i++)
#define for1(i, n) for(int i = 1; i <= (n);i++)
using namespace std;
int a[123456], t[123456], n, l, ans=0;
signed main() {
	cin>>n>>l;
	for1(i, n)cin>>a[i];
	for1(i, n){
		if(a[i-1]<a[i]&&a[i]>a[i+1]){
			t[i]=l-a[i];
			int k=i-1;
			while(k>0){
				if(a[k-1]<a[k]&&a[k]<a[k+1]){
					t[k]=t[k+1]+l-a[k];
				}
				else if(a[k-1]>a[k]&&a[k]<a[k+1]){
					t[k]=max(t[k-1],t[k+1])+l-a[k];
					break;
				}
				k--;
			}
			k=i+1;
			while(k<=n){
				if(a[k-1]>a[k]&&a[k]>a[k+1]){
					t[k]=t[k-1]+l-a[k];
				}
				else break;
				k++;
			}
		}
	}
	for1(i, n)ans=max(ans, t[i]);
	cout<<ans<<endl;
}
