#include <bits/stdc++.h>
using namespace std;
int a[100005];
int qsa[100005];
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) {
    scanf("%d", a + i);
    qsa[i] = qsa[i - 1] + (i % 2 ? a[i] - a[i - 1] : 0);
  }
  if (n % 2 == 0) {
    n++;
    qsa[n] = qsa[n - 1] + m - a[n - 1];
    a[n] = m;
  } else {
    n++;
    qsa[n] = qsa[n - 1];
    a[n] = m;
  }
  int ans = max(qsa[n], m - qsa[n]);
  for (int i = 1; i <= n; i++) {
    if (a[i] + 1 != a[i + 1]) {
      ans = max(ans, qsa[i] + a[n] - a[i] - qsa[n] + qsa[i] + (i % 2 ? -1 : 0));
    }
    if (a[i] - 1 != a[i - 1]) {
      ans = max(ans, qsa[i] + m - a[i] - qsa[n] + qsa[i] + (i % 2 ? -1 : 0));
    }
  }
  printf("%d", ans);
}
