#include <iostream>
#include <vector>

using namespace std;

#define MAX(a,b) ((a)>(b)?(a):(b))

int main()
{
    long long N,L;

    cin >> N >> L;

    vector<long long> a;

    a.push_back(0);
    for(int i=1; i<=N; ++i) {
        long long temp;
        cin >> temp;
        a.push_back(temp);
    }
    a.push_back(0);

    long long z=0,g=0,ans=0;

    for(int i=1; i<=N; ++i) {
        if(a[i-1]>a[i] && a[i]<a[i+1]) {
            g+=L-a[i];
            ans=MAX(ans,g);
            g=0;
            z=L-a[i];
        } else if(a[i-1]<a[i] && a[i]>a[i+1]) {
            z+=L-a[i];
            ans=MAX(ans,z);
            z=0;
            g=L-a[i];
        } else if(a[i-1]<a[i] && a[i]<a[i+1]) {
            z+=L-a[i];
        } else if(a[i-1]>a[i] && a[i]>a[i+1]) {
            g+=L-a[i];
        }
    }

    ans=MAX(ans,g);
    ans=MAX(ans,z);

    cout << ans << endl;

    return 0;
}