#include <bits/stdc++.h>
using namespace std;
int n, m, ans, s[100005], p[100005], cur, a[100005];
void solve() {
  cin >> n >> m;
  for (int i = 1; i < n + 1; i++) {
    cin >> a[i];
  }
  s[n] = m - a[n];
  for (int j = n - 1; j >= 0; j--) {
    s[j] = m - a[j] - s[j + 1];
  }
  ans = s[0];
  for (int i = 1; i < n + 1; i++) {
    if (i % 2) {
      ans = max(ans, a[i] - 1 - a[i - 1] + s[i] + cur);
    } else {
      ans = max(ans, a[i] - 1 - a[i - 1] + s[i + 1] + cur);
    }
    if (i % 2) cur += a[i] - a[i - 1];
  }
  if (n % 2) {
    ans = max(ans, cur + m - a[n] - 1);
  }
  cout << ans << '\n';
}
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
