#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  ll n, m;
  cin >> n >> m;
  ll ar[n + 2];
  ar[0] = 0;
  ar[n + 1] = m;
  ll ma = 0, s = 0;
  for (ll i = 1; i < n + 1; i++) {
    cin >> ar[i];
  }
  vector<ll> d;
  for (ll i = 0; i < n + 1; i++) {
    d.push_back((ar[i + 1] - ar[i]));
  }
  vector<ll> sd(d.size(), 0);
  for (ll i = d.size() - 1; i >= 0; i--) {
    if ((i + 1) & 1) {
      s += d[i];
    }
    sd[i] = s;
  }
  ma = s;
  ll ss = 0;
  for (ll i = 0; i < d.size(); i++) {
    if (d[i] > 1) {
      ma = max(ss + d[i] - 1 + m - ar[i + 1] - (sd[i] - ((i & 1) == 0) * d[i]),
               ma);
    }
    if ((1 + i) & 1) {
      ss += d[i];
    }
  }
  cout << ma << "\n";
}
