#include<bits/stdc++.h>
#define N 100005
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
ll n,l,a[N],d[N],ans;
priority_queue<P> q;

int main(){
  cin>>n>>l;
  for(int i=1;i<=n;i++){
    cin>>a[i];
    q.push(P(a[i],i));
  }
  while(!q.empty()){
    P t=q.top(); q.pop();
    ll len=t.first,idx=t.second;
    d[idx]=max(d[idx-1],d[idx+1])+l-len;
    ans=max(ans,d[idx]);
  }
  cout<<ans<<endl;
  return 0;
}