#include <bits/stdc++.h>
using namespace std;
using ull = unsigned long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vpii = vector<pii>;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, m;
  cin >> n >> m;
  vi a(n + 2);
  for (int i{1}; i <= n; ++i) cin >> a[i];
  a[n + 1] = m;
  vi l(n + 2);
  for (int i{n}; i >= 0; --i) {
    l[i] = a[i + 1] - a[i];
    if (i < n - 1) {
      l[i] += l[i + 2];
    }
  }
  int cl{0}, bl{0};
  for (int i{0}; i <= n; ++i) {
    bool on = i % 2 == 0;
    int il;
    if (on) {
      il = cl + max(l[i], a[i + 1] - a[i] - 1 + l[i + 1]);
      cl += a[i + 1] - a[i];
    } else {
      il = cl + max(l[i + 1], l[i] - 1);
    }
    bl = max(bl, il);
  }
  cout << bl << endl;
  return 0;
}
