#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 5;
long long n, m;
long long arr[MAXN];
vector<long long> part;
long long even[MAXN], odd[MAXN];
int main() {
  scanf("%lld%lld", &n, &m);
  for (int i = 0; i < n; i++) scanf("%lld", &arr[i]);
  part.push_back(arr[0]);
  for (int i = 0; i < n - 1; i++) {
    part.push_back(arr[i + 1] - arr[i]);
  }
  part.push_back(m - arr[n - 1]);
  long long ans = 0;
  int emx = 0, omx = 0;
  for (int i = 0; i < part.size(); i += 2) {
    if (i)
      even[i] += even[i - 2] + part[i];
    else
      even[i] = part[i];
    ans = max(ans, even[i]);
    emx = max(emx, i);
  }
  for (int i = 1; i < part.size(); i += 2) {
    if (i >= 3)
      odd[i] += odd[i - 2] + part[i];
    else
      odd[i] = part[i];
    omx = max(omx, i);
  }
  for (int i = 0; i < part.size(); i++) {
    if (part[i] == 1) continue;
    if (i & 1) {
      ans = max(ans, even[i - 1] + odd[omx] - odd[i] + part[i] - 1);
    } else {
      ans = max(ans, (i - 2 <= 0 ? 0 : even[i - 2]) + odd[omx] -
                         (i - 1 >= 0 ? odd[i - 1] : 0));
    }
  }
  printf("%lld\n", ans);
  return 0;
}
