#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const double eps = 1e-6, pi = 3.1415926535;
const int inf = 0x3f3f3f3f, maxn = 1e5 + 10;
int n, M;
int a[maxn];
void init() {}
int main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  long long cnt = 0;
  long long ans[maxn];
  long long ans1[maxn];
  long long div;
  cin >> n >> M;
  for (int i = (1); i <= n + 1; ++i) {
    if (i != n + 1)
      cin >> a[i];
    else
      a[i] = M;
    if (i % 2) {
      ans[i] = a[i] - a[i - 1];
      cnt += ans[i];
      if (i > 2) ans[i] += ans[i - 2];
    } else
      ans1[i] = a[i] - a[i - 1] + ans1[i - 2];
  }
  if (n % 2) {
    for (int i = (1); i <= n; ++i) {
      long long tmp = 0;
      if (a[i] - a[i - 1] == 1 && a[i + 1] - a[i] == 1) continue;
      if (i % 2) {
        tmp = ans[i] - 1 + ans1[n + 1] - ans1[i + 1 - 2];
      } else {
        tmp = ans[i - 1] + 1 + ans1[n + 1] - ans1[i];
      }
      cnt = max(cnt, tmp);
    }
  } else {
    for (int i = (1); i <= n; ++i) {
      long long tmp = 0;
      if (a[i] - a[i - 1] == 1 && a[i + 1] - a[i] == 1) continue;
      if (i % 2) {
        tmp = ans[i] - 1 + ans1[n] - ans1[i + 1 - 2];
      } else {
        tmp = ans[i - 1] + 1 + ans1[n] - ans1[i];
      }
      cnt = max(cnt, tmp);
    }
  }
  cout << cnt << endl;
  return 0;
}
