#include <bits/stdc++.h>
using namespace std;
int n, m, ANS, sm, place = 0, N;
vector<int> a, cwx;
set<int> s;
int main() {
  int cnt = 0;
  int flag = 0, re, u, v;
  scanf("%d%d", &n, &m);
  N = n + 1;
  a.push_back(0);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &re);
    a.push_back(re);
    s.insert(re);
  }
  if (n % 2 == 0) {
    a.push_back(m);
    N++;
    flag = 1;
  }
  for (int i = 0, j = i + 1; i < N; i += 2, j = i + 1) {
    u = a[i];
    v = a[j];
    sm -= (u - v);
    cwx.push_back(sm);
    cnt++;
    cwx.push_back(sm + 1);
    cnt++;
  }
  ANS = sm;
  for (int i = 0; i < n; i++) {
    if (flag && i == n - 1) {
      break;
    }
    if (s.count(a[i + 1] + 1) && s.count(a[i + 1] - 1)) {
      continue;
    }
    int now = cwx[i], ex = sm - now, et = m - a[i + 1] - 1;
    if (ANS < now + et - ex) {
      place = a[i + 1] + 1;
    }
    ANS = max(ANS, now + et - ex);
  }
  printf("%d\n", ANS);
  return 0;
}
