#include <bits/stdc++.h>
using namespace std;
const int N = 100005;
long long ans;
long long p[N], q[N], a[N];
void solve() {
  long long n, m;
  cin >> n >> m;
  a[0] = 0;
  a[n + 1] = m;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 1; i <= n + 1; i++) {
    p[i] = p[i - 1];
    if (i % 2) p[i] += (a[i] - a[i - 1]);
  }
  ans = p[n + 1];
  for (int i = n; i >= 0; i--) {
    q[i] = q[i + 1];
    if (i % 2) q[i] += (a[i + 1] - a[i]);
  }
  for (int i = 0; i <= n; i++) {
    long long res = p[i];
    if (i % 2) {
      res += a[i + 1] - (a[i] + 1);
      res += q[i + 1];
    } else {
      res += a[i + 1] - 1 - a[i];
      res += q[i + 1];
    }
    ans = max(res, ans);
  }
  cout << ans << endl;
}
int main() {
  int t;
  t = 1;
  for (int i = 0; i < t; i++) {
    solve();
  }
  return 0;
}
