#include <bits/stdc++.h>
using namespace std;
int N, L, d, bot, ans, tempo;
vector<int> a, ex, t;
int main() {
  cin >> N >> L;
  for (int i = 0; i < N; i++) {
    cin >> d;
    a.push_back(d);
    t.push_back(L - d);
  }
  for (int i = 1; i < N - 1; i++) {
    if ((a[i - 1] > a[i] && a[i] < a[i + 1]) ||
        (a[i - 1] < a[i] && a[i] > a[i + 1])) {
      ex.push_back(i);
    }
  }
  ex.push_back(N - 1);
  for (int i = 0; i < ex.size(); i++) {
    for (int j = bot; j <= ex[i]; j++) {
      tempo += t[j];
    }
    ans = max(ans, tempo);
    tempo = 0;
    bot = ex[i];
  }
  cout << ans << endl;
}
