#include <bits/stdc++.h>
using namespace std;
const long long modulo = 1000000007;
const int inf = 0x3f3f3f3f;
const long long ll_inf = 0x3f3f3f3f3f3f3f3f;
int main() {
  int n, M;
  cin >> n >> M;
  int a[n];
  int baseline = 0;
  int lasti = 0;
  bool on = true;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (on) baseline += a[i] - lasti;
    lasti = a[i];
    on = !on;
  }
  if (on) baseline += M - lasti;
  on = (n % 2 == 0);
  int on_ph = 0;
  int off_ph = 0;
  int max_diff = 0;
  int i_ph = M;
  for (int i = n - 1; i >= 0; i--) {
    if (on)
      on_ph += i_ph - a[i];
    else
      off_ph += i_ph - a[i];
    if (a[i] + 1 < i_ph) {
      if ((off_ph - 1 + on) - (on_ph - on) > max_diff)
        max_diff = (off_ph - 1 + on) - (on_ph - on);
    }
    int lowerbound = i > 0 ? a[i - 1] : 0;
    if (a[i] - 1 > lowerbound) {
      if ((off_ph + on) - (on_ph + 1 - on) > max_diff)
        max_diff = (off_ph + on) - (on_ph + 1 - on);
    }
    i_ph = a[i];
    on = !on;
  }
  if (on)
    on_ph += a[0];
  else
    off_ph += a[0];
  if (a[0] > 1) {
    if ((off_ph + 1 - on) - (on_ph - on) > max_diff)
      max_diff = (off_ph + 1 - on) - (on_ph - on);
  }
  cout << baseline + max_diff << endl;
}
