#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
int a[N], pre[N], suf[N], suf2[N];
int main() {
  int n, M;
  cin >> n >> M;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  a[n + 1] = M;
  for (int i = 1; i <= n + 1; i += 2) {
    if (i == 1)
      pre[i] = a[i] - a[i - 1];
    else
      pre[i] = pre[i - 2] + a[i] - a[i - 1];
  }
  for (int i = n; i >= 0; i -= 2) {
    suf[i] = suf[i + 2] + a[i + 1] - a[i];
  }
  for (int i = n - 1; i >= 0; i -= 2) {
    suf2[i] = suf2[i + 2] + a[i + 1] - a[i];
  }
  int ans = 0;
  ans = max(pre[n + 1], pre[n]);
  if (n & 1)
    ans = max(ans, pre[n] + M - a[n] - 1);
  else
    ans = max(ans, pre[n - 1] + M - 1 - a[n]);
  for (int i = 1; i <= n; i++) {
    int hou = 0, qian = 0;
    if (i & 1) {
      if (i >= 2) qian = pre[i - 2];
      if (n & 1)
        hou = suf[i + 1];
      else
        hou = suf2[i + 1];
      ans = max(ans, qian + a[i] - 1 - a[i - 1] + hou);
    } else {
      qian = pre[i - 1];
      if (n & 1)
        hou = suf[i + 1];
      else
        hou = suf2[i + 1];
      ans = max(ans, qian + a[i] - (a[i - 1] + 1) + hou);
    }
  }
  cout << ans;
  return 0;
}
