#include <bits/stdc++.h>
using namespace std;
template <class T>
inline T bigMod(T p, T e, T M) {
  long long ret = 1;
  for (; e > 0; e >>= 1) {
    if (e & 1) ret = (ret * p) % M;
    p = (p * p) % M;
  }
  return (T)ret;
}
template <class T>
inline T modInverse(T a, T M) {
  return bigMod(a, M - 2, M);
}
template <class T>
inline T gcd(T a, T b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
template <class T>
inline T lcm(T a, T b) {
  a = abs(a);
  b = abs(b);
  return (a / gcd(a, b)) * b;
}
template <class T>
inline string int2String(T a) {
  ostringstream str;
  str << a;
  return str.str();
}
template <class T>
inline T string2int(string a) {
  stringstream str(a);
  T b;
  str >> b;
  return b;
}
const int dr[] = {0, 1, 0, -1, -1, 1, 1, -1, -2, -2, 2, 2, -1, -1, 1, 1};
const int dc[] = {1, 0, -1, 0, 1, 1, -1, -1, -1, 1, -1, 1, -2, 2, -2, 2};
long long n, m;
long long ar[200005];
long long rightSum[200005], leftSum[200005];
int rightw(int pos) {
  if (pos + 1 > n) return rightSum[pos] = 0;
  return rightSum[pos] = ar[pos + 1] - ar[pos] + rightw(pos + 2);
}
void leftw(int pos, long long sum) {
  if (pos > n) return;
  leftSum[pos] = sum + ar[pos] - ar[pos - 1];
  leftw(pos + 2, leftSum[pos]);
}
int main() {
  scanf("%lld %lld", &n, &m);
  for (int i = int(1); i < int(n + 1); i++) {
    scanf("%lld", &ar[i]);
  }
  ar[0] = 0;
  ar[++n] = m;
  long long mx = rightw(0);
  rightw(1);
  leftw(1, 0);
  for (int i = 1; i <= n; i += 2) {
    if (ar[i] - 1 > ar[i - 1]) {
      mx = max(mx, (i == 1 ? 0 : leftSum[i - 2]) + ar[i] - 1 - ar[i - 1] +
                       rightSum[i]);
    }
    if (i + 1 <= n && ar[i] + 1 != ar[i + 1]) {
      mx = max(mx, leftSum[i] + ar[i + 1] - ar[i] - 1 + rightSum[i + 2]);
    }
  }
  printf("%lld\n", mx);
  return 0;
}
