#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, m;
  cin >> n >> m;
  long long int arr[n];
  vector<long long int> a, onsum, offsum;
  for (long long int i = 0; i < n; i++) {
    cin >> arr[i];
  }
  a.push_back(arr[0]);
  for (long long int i = 1; i < n; i++) {
    a.push_back(arr[i] - arr[i - 1]);
  }
  a.push_back(m - arr[n - 1]);
  long long int sum1 = 0, sum2 = 0;
  for (long long int i = 0; i < a.size(); i++) {
    if (i % 2 == 0) {
      sum1 = sum1 + a[i];
      offsum.push_back(sum1);
    } else {
      sum2 = sum2 + a[i];
      onsum.push_back(sum2);
    }
  }
  long long int sum = 0;
  vector<long long int> z;
  for (long long int i = 0; i < onsum.size(); i++) {
    if (i == 0)
      sum = offsum[i] + onsum[onsum.size() - 1] - 1;
    else
      sum = offsum[i] + onsum[onsum.size() - 1] - onsum[i - 1] - 1;
    z.push_back(sum);
  }
  sum = 0;
  for (long long int i = 0; i < a.size(); i++) {
    if (i % 2 == 0) sum = sum + a[i];
  }
  z.push_back(sum);
  sort(z.begin(), z.end());
  cout << z[z.size() - 1];
  return 0;
}
