#include <bits/stdc++.h>
using namespace std;
long long i, j, k, n, m, a[200009], cm1[200009], cm2[200009], ans, sum, c;
int main() {
  cin >> n >> m;
  for (i = 1; i <= n; i++) cin >> a[i];
  a[n + 1] = m;
  for (i = 1; i <= n + 1; i++) {
    if (i % 2 != 0) {
      cm1[i] = cm1[i - 1] + a[i] - a[i - 1];
      cm2[i] = cm2[i - 1];
    } else {
      cm2[i] = cm2[i - 1] + a[i] - a[i - 1];
      cm1[i] = cm1[i - 1];
    }
  }
  ans = max(ans, cm1[n + 1]);
  ans = max(ans, cm2[n + 1]);
  for (i = 0; i <= n; i++) {
    sum = 0;
    if (i % 2 == 0)
      c = a[i + 1] - 1;
    else
      c = a[i] + 1;
    if (!(c > a[i] && c < a[i + 1])) continue;
    if (i % 2 == 0) {
      sum += c - a[i];
      sum += cm2[n + 1] - cm2[i];
      sum += cm1[i];
    } else {
      sum += c - a[i];
      sum += cm1[n + 1] - cm1[i];
      sum += cm2[i];
    }
    ans = max(ans, sum);
  }
  cout << ans << endl;
  return 0;
}
