#include<iostream>
#include<algorithm>
using namespace std;

long long dp[100100];
int n,l;
int a[100100];

long long rec(int p){
  if(0<=dp[p])return dp[p];

  if(a[p-1] < a[p] && a[p] < a[p]){
    return dp[p] = l-a[p];
  }

  long long tmp = 0;
  if(a[p]<a[p-1])tmp = max(tmp,dp[p-1]);
  if(a[p]<a[p+1])tmp = max(tmp,rec(p+1));
  return dp[p]= l-a[p] + tmp;
}
  
int main(){
  long long ans;
  cin >> n >> l;
  for(int i=1;i<=n;i++){
    cin >> a[i];
    dp[i] = -1;
  }
  a[0] = a[n+1] = dp[0] = dp[n+1] = 0;

  ans = 0;
  for(int i=1;i<=n;i++)ans = max(ans,rec(i));

  cout << ans << endl;
}