#include<cstdio>
#include<vector>
using namespace std;
int main()
{
	int N,L;
	scanf("%d%d",&N,&L);
	int X[100002];
	X[0]=0;
	X[N+1]=0;
	int XW[100002];
	for(int i=1;i<=N;i++){
		scanf("%d",&X[i]);
	}
	int ans=0;
	vector<int>A,B;
	A.push_back(0);
	for(int i=1;i<=N;i++){
		if(X[i-1]<X[i]&&X[i]>X[i+1])B.push_back(i);
		else if(X[i-1]>X[i]&&X[i]<X[i+1])A.push_back(i);
	}
	A.push_back(N+1);
	for(int i=1;i<=N+2;i++){
		X[i-1]=L-X[i-1];
		if(i==1||i==N+2)X[i-1]=0;
		if(i==1)XW[i]=X[i-1];
		else XW[i]=XW[i-1]+X[i-1];
		//printf("%d\n",XW[i]);
	}
	XW[0]=0;
	for(int i=0;i<B.size();i++){
		ans=max(ans,max(XW[B[i]+1]-XW[A[i]],XW[A[i+1]+1]-XW[B[i]]));
		//printf("%d %d %d\n",A[i],B[i],XW[B[i]+1]-XW[A[i]]);
		//printf("%d %d %d\n",B[i],A[i+1],XW[A[i+1]+1]-XW[B[i]]);
	}
	printf("%d\n",ans);
	return 0;
}