#include <bits/stdc++.h>
using namespace std;
int n, M;
vector<int> a;
inline bool read() {
  if (!(cin >> n >> M)) return false;
  a.assign(n, 0);
  for (int i = 0; i < n; i++) scanf("%d", &a[i]);
  return true;
}
vector<int> f[2];
inline void solve() {
  a.insert(a.begin(), 0);
  a.push_back(M);
  f[0].assign(a.size(), 0);
  f[1].assign(a.size(), 0);
  for (int i = int(a.size()) - 2; i >= 0; i--) {
    f[0][i] = f[1][i + 1];
    f[1][i] = (a[i + 1] - a[i]) + f[0][i + 1];
  }
  int ans = f[1][0];
  for (int i = 0; i + 1 < int(a.size()); i++) {
    if (a[i + 1] - a[i] < 2) continue;
    int tp = (i & 1) ^ 1;
    int pSum = f[1][0] - f[tp][i];
    ans = max(ans, pSum + (a[i + 1] - a[i] - 1) + f[tp][i + 1]);
  }
  cout << ans << endl;
}
int main() {
  if (read()) solve();
  return 0;
}
