#include <bits/stdc++.h>
using namespace std;
int main() {
  int i, j, k, n, m;
  cin >> n >> m;
  int a[n];
  for (i = 0; i < n; i++) cin >> a[i];
  vector<int> V;
  if (a[0] != 0) V.push_back(a[0]);
  for (i = 0; i < n - 1; i++) V.push_back(a[i + 1] - a[i]);
  if (a[n - 1] != m) {
    V.push_back(m - a[n - 1]);
  }
  int ma = 0;
  n = V.size();
  vector<int> b(n + 3, 0), c(n + 3, 0), d(n + 3, 0), e(n + 3, 0);
  b[0] = V[0];
  for (i = 2; i < n; i += 2) b[i] = b[i - 2] + V[i];
  c[1] = V[1];
  for (i = 3; i < n; i += 2) c[i] = c[i - 2] + V[i];
  d[n - 1] = V[n - 1];
  for (i = n - 3; i >= 0; i -= 2) d[i] = d[i + 2] + V[i];
  e[n - 2] = e[i + 2] + V[n - 2];
  for (i = n - 4; i >= 0; i -= 2) e[i] = e[i + 2] + V[i];
  long long mx = e[0] + d[0];
  for (i = 0; i < n; i++) {
    if (V[i] == 1) continue;
    if (i % 2 == 0) {
      long long res = b[i] + c[i] - 1 + d[i + 1] + e[i + 1];
      mx = max(res, mx);
    } else {
      long long res = b[i - 1] + c[i - 1] + V[i] - 1 + d[i + 2] + e[i + 2];
      mx = max(mx, res);
    }
  }
  cout << mx;
}
