#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, M;
  cin >> n >> M;
  int prev = 0;
  vector<pair<int, bool>> all;
  all.push_back({0, true});
  bool lit = false;
  int time{0};
  vector<int> times;
  times.push_back(0);
  for (int i = 0; i <= n; i++) {
    if (i != n) {
      int t;
      cin >> t;
      all.push_back({t, lit});
      if (lit) {
        lit = false;
        times.push_back(time);
      } else if (!lit) {
        time += all[i + 1].first - all[i].first;
        lit = true;
        times.push_back(time);
      }
    } else {
      all.push_back({M, false});
      if (lit) {
        lit = false;
        times.push_back(time);
      } else if (!lit) {
        time += all[i + 1].first - all[i].first;
        lit = false;
        times.push_back(time);
      }
    }
  }
  int timelit{0};
  int timeunlit{0};
  int maxtime = times.back();
  for (int i = n + 1; i > 0; i--) {
    if (all[i - 1].second == false) {
      timeunlit += all[i].first - all[i - 1].first;
      if (all[i].first - all[i - 1].first > 1) {
        maxtime = max(maxtime, times.back() + timeunlit - timelit - 1);
      }
    } else {
      timelit += all[i].first - all[i - 1].first;
      if (all[i].first - all[i - 1].first > 1) {
        maxtime = max(maxtime, times.back() + timeunlit - timelit + 1);
      }
    }
  }
  cout << maxtime;
}
