#include <bits/stdc++.h>
using namespace std;
int n, M;
int a[100005];
int pre[100005], nxt[100005];
int sum1[100005], sum2[100005];
int main() {
  cin >> n >> M;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  a[0] = 0, a[n + 1] = M;
  for (int i = 0; i <= n + 1; i += 2) {
    pre[i] = a[i + 1] - a[i];
    nxt[i + 1] = a[i + 2] - a[i + 1];
    sum1[i + 2] = ((i - 2 < 0) ? 0 : sum1[i]) + pre[i];
    sum2[i + 1] = ((i - 1 < 0) ? 0 : sum2[i - 1]) + nxt[i + 1];
  }
  int maxx = -1;
  for (int i = 1; i <= n; i++) {
    int ans = 0;
    if (i % 2 == 1)
      ans = sum1[i - 1] + (a[i] - 1 - a[i - 1]) +
            (sum2[n] == 0 ? sum2[n - 1] : sum2[n]) - sum2[i - 2];
    else
      ans = sum1[i - 1] + (a[i] - a[i - 1] - 1) +
            (sum2[n] == 0 ? sum2[n - 1] : sum2[n]) - sum2[i - 1];
    maxx = max(maxx, ans);
  }
  cout << max(maxx, sum1[n + 1] == 0 ? sum1[n + 2] : sum1[n + 1]);
  return 0;
}
