#include <bits/stdc++.h>
using namespace std;
int a[1000000];
int l[1000000];
int n, m;
int main() {
  cin >> n >> m;
  a[0] = 0;
  l[0] = 0;
  for (int i = 1; i <= n; i++) cin >> a[i];
  bool f = 1;
  for (int i = 1; i <= n; i++) {
    l[i] = l[i - 1] + f * (a[i] - a[i - 1]);
    f = !f;
  }
  l[n + 1] = l[n] + f * (m - a[n]);
  int ans = l[n + 1];
  for (int i = 1; i <= n; i++) {
    ans = max(ans, l[i] + m - a[i] - (l[n + 1] - l[i]) - 1);
  }
  cout << ans;
  return 0;
}
