#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  long long n, m;
  cin >> n >> m;
  long long a[n + 1];
  a[n] = m;
  for (int i = 0; i < n; ++i) cin >> a[i];
  long long o[n], of[n];
  of[n - 1] = 0;
  o[n - 1] = m - a[n - 1];
  for (int i = n - 2; i >= 0; --i) {
    o[i] = a[i + 1] - a[i] + of[i + 1];
    of[i] = o[i + 1];
  }
  long long ans = of[0] + a[0], no = of[0] + a[0];
  for (int i = 0; i < n; ++i) {
    if (i == 0) {
      if (a[i] != 1 || a[i] != a[i + 1] - 1) {
        if (i % 2 == 0) {
          if (ans < no - of[i] + o[i] - 1) ans = no - of[i] + o[i] - 1;
        } else {
          if (ans < no - o[i] + of[i] - 1) ans = no - o[i] + of[i] - 1;
        }
      }
    } else {
      if (a[i] != a[i - 1] + 1 || a[i] != a[i + 1] - 1) {
        if (i % 2 == 0) {
          if (ans < no - of[i] + o[i] - 1) ans = no - of[i] + o[i] - 1;
        } else {
          if (ans < no - o[i] + of[i] - 1) ans = no - o[i] + of[i] - 1;
        }
      }
    }
  }
  cout << ans;
}
