#include <bits/stdc++.h>
using namespace std;
int a[100050];
int main() {
  ios_base::sync_with_stdio(false);
  int i, j, k, n, m, t, y, temp;
  cin >> n >> m;
  for (i = 1; i <= n; i++) {
    cin >> a[i];
  }
  a[0] = 0;
  a[n + 1] = m;
  long long on = 0;
  long long off = 0;
  int pre = 0;
  for (i = 1; i <= n + 1; i++) {
    if (pre == 0) {
      on += a[i] - a[i - 1];
      pre = 1;
    } else {
      off += a[i] - a[i - 1];
      pre = 0;
    }
  }
  pre = 0;
  long long mon = on;
  long long lon = 0;
  long long loff = 0;
  long long roff, ron;
  for (i = 1; i <= n + 1; i++) {
    roff = off - loff;
    if (pre == 0) {
      if (a[i] - a[i - 1] == 1) {
        lon += 1;
        pre = 1;
        continue;
      }
      long long t = lon + roff + (a[i] - a[i - 1] - 1);
      lon += a[i] - a[i - 1];
      mon = max(mon, t);
      pre = 1;
    } else {
      if (a[i] - a[i - 1] == 1) {
        loff += 1;
        pre = 0;
        continue;
      }
      roff -= (a[i] - a[i - 1]);
      long long t = lon + roff + (a[i] - a[i - 1] - 1);
      loff += a[i] - a[i - 1];
      mon = max(mon, t);
      pre = 0;
    }
  }
  cout << mon;
  return 0;
}
