#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9;
const double eps = 0;
const int ms = 0;
const int md = 0;
int n, m;
vector<int> a;
long long pf[2][100005];
int main() {
  cin >> n >> m;
  a.push_back(0);
  for (__typeof(1) i = 1; i < n + 1; i++) {
    int x;
    cin >> x;
    a.push_back(x);
  }
  a.push_back(m);
  memset(pf[0], 0, sizeof(pf[0]));
  memset(pf[1], 0, sizeof(pf[1]));
  for (__typeof(int(a.size() - 2)) i = int(a.size() - 2); i >= 0; i--) {
    pf[0][i] = pf[1][i + 1];
    pf[1][i] = (a[i + 1] - a[i]) + pf[0][i + 1];
  }
  long long ans = pf[1][0];
  for (__typeof(0) i = 0; i < int(a.size() - 1); i++) {
    if (a[i + 1] - a[i] >= 2) {
      int idx = !(i % 2);
      long long pfsum = pf[1][0] - pf[idx][i];
      ans = max(ans, pfsum + (a[i + 1] - a[i] - 1) + pf[idx][i + 1]);
    }
  }
  cout << ans << endl;
  return 0;
}
