#include <bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(a) (a).begin(),(a).end()
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
const int INF=1e9;
const int MOD=1000000007;
int s[100003],d[100003];
int main(){
      int n,l;
      cin>>n>>l;
      priority_queue<P> Q;
      REP(i,n){
            cin>>d[i+1];
            Q.push(P(d[i+1],i+1));
      }
      int ans=0;
      while(!Q.empty()){
            P p=Q.top();Q.pop();
            s[p.second]=max(s[p.second-1],s[p.second+1])+(l-p.first);
            ans=max(ans,s[p.second]);
      }
      cout<<ans<<endl;
}