#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  long long t = 1;
  while (t--) {
    long long n, m;
    cin >> n >> m;
    long long v[n];
    for (long long i = 0; i < n; i++) cin >> v[i];
    vector<long long> a;
    a.push_back(0);
    for (long long i = 0; i < n; i++) a.push_back(v[i]);
    a.push_back(m);
    n = a.size();
    long long postsum[n];
    postsum[n - 1] = a[n - 1];
    postsum[n - 2] = a[n - 2];
    for (long long i = n - 3; i >= 0; i -= 2)
      postsum[i] = postsum[i + 2] + a[i];
    for (long long i = n - 4; i >= 0; i -= 2)
      postsum[i] = postsum[i + 2] + a[i];
    long long presum[n];
    presum[0] = a[0];
    presum[1] = a[1];
    for (long long i = 2; i < n; i += 2) presum[i] = presum[i - 2] + a[i];
    for (long long i = 3; i < n; i += 2) presum[i] = presum[i - 2] + a[i];
    long long ans = 0;
    if (n % 2 == 0 && n - 2 >= 0)
      ans = presum[n - 1] - presum[n - 2];
    else if (n % 2 == 1 && n - 3 >= 0)
      ans = presum[n - 2] - presum[n - 3];
    for (long long i = 0; i < n - 1; i++) {
      if (a[i] + 1 == a[i + 1]) continue;
      long long var, currans = 0;
      long long leftans = 0, rightans = 0;
      if (i % 2 == 0) {
        var = a[i + 1] - 1;
        if (i > 1) leftans = presum[i - 1] - presum[i - 2];
        rightans = var - a[i];
        if (i + 2 < n) {
          rightans += postsum[i + 2] - postsum[i + 1];
          if ((n - i - 1) % 2 == 1) rightans += a[n - 1];
        }
      } else {
        var = a[i] + 1;
        if (i > 0) leftans = presum[i] - presum[i - 1];
        rightans = a[i + 1] - var;
        if (i + 3 < n) {
          rightans += postsum[i + 3] - postsum[i + 2];
          if ((n - i - 1) % 2 == 0) rightans += a[n - 1];
        }
      }
      currans = leftans + rightans;
      ans = max(ans, currans);
    }
    cout << ans << endl;
  }
  return 0;
}
