#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
const long long INF = (long long)1000000007 * 1000000007;
const double EPS = 1e-9;
const long double eps = 1e-11;
const long double pi = acos(-1.0);
int d[100001] = {};
int a[100001] = {};
int main() {
  int n, m;
  cin >> n >> m;
  int sum = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  d[0] = a[0];
  sum = a[0];
  for (int i = 1; i < n; i++) {
    if (i % 2) {
      d[i] = d[i - 1];
    } else {
      d[i] = d[i - 1] + (a[i] - a[i - 1]);
      sum += a[i] - a[i - 1];
    }
  }
  if (n % 2 == 0) {
    sum += m - a[n - 1];
    d[n] = d[n - 1] + (m - a[n - 1]);
  } else {
    d[n] = d[n - 1];
  }
  int ma = sum;
  for (int i = 0; i < n; i++) {
    int x = sum - d[i];
    int y = m - a[i];
    int t = y - x;
    if (a[i] - a[i - 1] == 1) continue;
    if (i % 2 == 0) {
      ma = max(ma, d[i] - 1 + t);
    } else {
      ma = max(ma, d[i] + (a[i] - a[i - 1] - 1) + t);
    }
  }
  if (n % 2 && m - a[n - 1] > 1) {
    ma = max(ma, d[n] + (m - a[n - 1] - 1));
  }
  cout << ma << endl;
  return 0;
}
