#include <bits/stdc++.h>
using namespace std;
const int MAX = 1e5 + 5;
char ss[1 << 17], *A = ss, *B = ss;
inline char gc() {
  if (A == B) {
    B = (A = ss) + fread(ss, 1, 1 << 17, stdin);
    if (A == B) return EOF;
  }
  return *A++;
};
template <class T>
inline void sdf(T& x) {
  char c;
  register int y = 1;
  while (c = gc(), c < 48 || 57 < c)
    if (c == '-') y = -1;
  x = c ^ 48;
  while (c = gc(), 47 < c && c < 58) x = (x << 1) + (x << 3) + (c ^ 48);
  x *= y;
}
int n, m, maxn;
int a[MAX], sum[MAX];
int main() {
  sdf(n);
  sdf(m);
  for (int i = 1; i <= n; i++) {
    sdf(a[i]);
    sum[i] = sum[i - 1] + (i % 2 != 0 ? 1 : 0) * (a[i] - a[i - 1]);
  }
  n++;
  a[n] = m;
  sum[n] = sum[n - 1] + (n % 2 != 0 ? 1 : 0) * (a[n] - a[n - 1]);
  maxn = sum[n];
  for (int i = 1; i <= n; i++) {
    if (a[i - 1] != a[i] - 1)
      maxn = max(maxn, (m - a[i]) - (sum[n] - sum[i]) -
                           ((i % 2 == 0) ? -1 : 1) + sum[i - 1]);
    if (a[i] + 1 != a[i + 1] && i != n)
      maxn = max(maxn, (m - a[i + 1]) - (sum[n] - sum[i + 1]) +
                           ((i % 2 != 0) ? a[i + 1] - a[i] : 0) +
                           (i % 2 != 0 ? -1 : 1) + sum[i]);
  }
  cout << maxn;
  return 0;
}
