#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  vector<int> a(n + 2);
  for (int i = 1; i <= n; i++) cin >> a[i];
  a[0] = 0;
  a[n + 1] = m;
  int suff_on[n + 2];
  int suff_off[n + 2];
  int pref_on[n + 2];
  int pref_off[n + 2];
  pref_on[0] = 0;
  pref_off[0] = 0;
  for (int i = 1; i <= n + 1; ++i) {
    pref_off[i] = pref_off[i - 1];
    pref_on[i] = pref_on[i - 1];
    if (i % 2 == 1)
      pref_on[i] += a[i] - a[i - 1];
    else
      pref_off[i] += a[i] - a[i - 1];
  }
  suff_on[n + 1] = 0;
  suff_off[n + 1] = 0;
  for (int i = n; i >= 0; i--) {
    suff_on[i] = suff_on[i + 1];
    suff_off[i] = suff_off[i + 1];
    if (i % 2 == 0)
      suff_on[i] += a[i + 1] - a[i];
    else
      suff_off[i] += a[i + 1] - a[i];
  }
  int answer = pref_on[n + 1];
  for (int i = 0; i <= n; i++) {
    int e = pref_on[i] + suff_off[i];
    answer = max(answer, e - 1);
  }
  cout << answer << "\n";
  return 0;
}
