#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long n, m;
  cin >> n >> m;
  std::vector<long long> v(n);
  long long cnt = 0;
  int tgl = 1;
  for (int i = 0; i < n; ++i) {
    cin >> v[i];
    if (tgl) cnt += v[i] - (i == 0 ? 0 : v[i - 1]);
    tgl = (tgl + 1) % 2;
  }
  if (tgl) cnt += m - v.back();
  std::vector<pair<long long, long long> > p(n);
  tgl = (n + 1) % 2;
  pair<long long, long long> ans = {-1, 0};
  for (int i = n - 1; i >= 0; --i) {
    if (i == n - 1) {
      if (tgl)
        p.back() = {m - v.back(), 0};
      else
        p.back() = {0, m - v.back()};
    } else {
      if (!tgl) {
        p[i] = {p[i + 1].first, v[i + 1] - v[i] + p[i + 1].second};
      } else {
        p[i] = {v[i + 1] - v[i] + p[i + 1].first, p[i + 1].second};
      }
    }
    if (p[i].second - p[i].first > ans.second &&
        ((i == n - 1 ? v[i] + 1 != m : v[i + 1] != v[i] + 1) ||
         (i == 0 ? v[i] - 1 != 0 : v[i - 1] != v[i] - 1)))
      ans = {v[i] + 1, p[i].second - p[i].first};
    tgl = (tgl + 1) % 2;
  }
  cout << (ans.first == -1 ? cnt : ans.second + cnt - 1) << endl;
  return 0;
}
