#include <bits/stdc++.h>
using namespace std;
int read() {
  int q = 0;
  char ch = ' ';
  while (ch < '0' || ch > '9') ch = getchar();
  while (ch >= '0' && ch <= '9') q = q * 10 + ch - '0', ch = getchar();
  return q;
}
const int N = 100005;
int a[N], b[N], x[N], n, m, ans = 0;
int main() {
  n = read(), m = read();
  for (register int i = 1; i <= n; ++i) x[i] = read();
  x[++n] = m;
  for (register int i = n; i >= 1; --i) {
    a[i] = a[i + 1], b[i] = b[i + 1];
    if (i != n) {
      if (i & 1)
        b[i] += x[i + 1] - x[i];
      else
        a[i] += x[i + 1] - x[i];
    }
    if (i != n && x[i + 1] != x[i] + 1) {
      int ka = b[i], kb = a[i];
      if (i & 1)
        ++kb, --ka;
      else
        ++ka, --kb;
      ans = max(ans, ka - a[i]);
    }
    if (x[i - 1] != x[i] - 1) {
      int ka = b[i], kb = a[i];
      if (i & 1)
        ++kb, --ka;
      else
        ++ka, --kb;
      ans = max(ans, ka - a[i]);
    }
  }
  printf("%d\n", a[1] + x[1] + ans);
  return 0;
}
