#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1.);
const long long mod = 1000000007;
int gcd(int a, int b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
long long lcm(int a, int b) {
  return ((long long)a * (long long)b) / gcd(a, b);
}
inline void prep() {
  cin.tie(0);
  cin.sync_with_stdio(0);
};
int main() {
  prep();
  int n, m;
  cin >> n >> m;
  vector<int> lst;
  lst.push_back(0);
  for (int i = 0; i < n; i++) {
    int num;
    cin >> num;
    lst.push_back(num);
  }
  lst.push_back(m);
  bool off = false;
  long long bef = 0;
  long long bef2 = 0;
  int arr[1000000];
  int arr2[1000000];
  int sz = lst.size() - 1;
  for (int i = 0; i < sz; i += 2) {
    bef += lst[i + 1] - lst[i];
    bef2 += lst[i + 2] - lst[i + 1];
    arr[i + 1] = bef;
    arr[i + 2] = bef;
    arr2[i + 2] = bef2;
    arr2[i + 3] = bef2;
  }
  arr[0] = 0;
  arr2[0] = 0;
  arr2[1] = 0;
  for (int i = 0; i < sz; i++) {
    long long now = 0;
    if (off && lst[i + 1] - lst[i] != 1) {
      int val = lst[i] + 1;
      now = arr[i];
      now += lst[i + 1] - val;
      now += arr2[sz] - arr2[i + 1];
    } else if (lst[i + 1] - lst[i] != 1) {
      int val = lst[i + 1] - 1;
      now = arr[i];
      now += val - lst[i];
      now += arr2[sz] - arr2[i + 1];
    }
    bef = max(now, bef);
    off = !off;
  }
  cout << bef;
  return 0;
}
