#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, m;
  cin >> n >> m;
  vector<long long int> A(n + 2);
  A[0] = 0;
  A[n + 1] = m;
  for (int i = 1; i <= n; i++) {
    cin >> A[i];
  }
  vector<long long int> diff(n + 2);
  for (int i = 1; i <= n + 1; i++) {
    diff[i] = A[i] - A[i - 1];
  }
  vector<long long int> sumodd(n + 3, 0);
  vector<long long int> sumeven(n + 3, 0);
  for (int i = n + 1; i >= 1; i--) {
    if (i % 2 == 1) {
      sumodd[i] = sumodd[i + 1] + diff[i];
    } else {
      sumodd[i] = sumodd[i + 1];
    }
    if (i % 2 == 0) {
      sumeven[i] = sumeven[i + 1] + diff[i];
    } else {
      sumeven[i] = sumeven[i + 1];
    }
  }
  long long int ans = sumodd[1];
  for (int i = 1; i <= n + 1; i++) {
    if (diff[i] > 1) {
      if (i % 2 == 1) {
        if (sumeven[i] + diff[i] - 1 > ans) {
          ans = sumeven[i] + diff[i] - 1;
        }
      } else if (i % 2 == 0) {
        if (sumeven[i] - 1 - sumodd[i] + sumodd[1] > ans) {
          ans = sumeven[i] - 1 - sumodd[i] + sumodd[1];
        }
      }
    }
  }
  cout << ans << endl;
}
