var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var arr=input.trim().split("\n");
var arr=input.trim().split("\n");
var NL=arr.shift().split(" ").map(Number);
var N=NL[0];
var L=NL[1];
arr.length=N;
arr=arr.map(Number);
var life=[];
for(var i=0;i<arr.length;i++)life[i]="";
for(var k=0;k<=100000;k++){
for(var i=0;i<arr.length;i++){
if(life[i]!="")continue;
if(i==0){
   if(arr[i]>arr[i+1])life[i]=L-arr[i];
   else if(life[i+1]!="")life[i]=life[i+1]+L-arr[i];
}else if(i==arr.length-1){
   if(arr[i]>arr[i-1])life[i]=L-arr[i];
   else if(life[i-1]!="") life[i]=life[i-1]+L-arr[i];
}else{
   if(arr[i]>arr[i-1] && arr[i]>arr[i+1])life[i]=L-arr[i];
   else if(arr[i]>arr[i-1] && arr[i]<arr[i+1] && life[i+1]!="")life[i]=life[i+1]+L-arr[i];
   else if(arr[i]<arr[i-1] && arr[i]>arr[i+1] && life[i-1]!="")life[i]=life[i-1]+L-arr[i];
   else if(arr[i]<arr[i-1] && arr[i]<arr[i+1] && life[i-1]!="" && life[i+1]!="")life[i]=Math.max(life[i-1],life[i+1])+L-arr[i];
}
}
}
var ans=0;
life.forEach(function(v){
   ans=Math.max(ans,v);
});
console.log(ans);