#include <bits/stdc++.h>
using namespace std;
long long n, M, a[100005], s[100005];
int main() {
  long long i;
  cin >> n >> M;
  cin >> a[1];
  s[1] = a[1];
  a[n + 1] = M;
  for (i = 2; i <= n; ++i) {
    cin >> a[i];
    s[i] = s[i - 2] + a[i] - a[i - 1];
  }
  s[n + 1] = s[n - 1] + M - a[n];
  long long maxi = s[n + 1], N = n + 1, act, n1, n2;
  if (n % 2 == 1) {
    n1 = N;
    n2 = N;
  } else {
    n1 = n;
    n2 = n;
  }
  for (i = 1; i <= N; i += 2) {
    act = (s[i] - 1) + (s[n1] - s[i - 1]);
    if (act > maxi) maxi = act;
  }
  for (i = 2; i <= N; i += 2) {
    act = (s[i - 1] + a[i] - a[i - 1] - 1) + (s[n2] - s[i]);
    if (act > maxi) maxi = act;
  }
  cout << maxi << '\n';
  return 0;
}
