#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
const int MOD2 = 998244353;
const int BASE = 29;
const long long int LLINF = 1ll << 60;
const char en = '\n';
void yes() {
  cout << "YES" << en;
  exit(0);
}
void no() {
  cout << "NO" << en;
  exit(0);
}
long long int raand() { return rand() * RAND_MAX + rand(); }
string to_upper(string a) {
  for (int i = 0; i < a.size(); ++i)
    if (a[i] >= 'a' && a[i] <= 'z') a[i] -= 'a' - 'A';
  return a;
}
string to_lower(string a) {
  for (int i = 0; i < a.size(); ++i)
    if (a[i] >= 'A' && a[i] <= 'Z') a[i] += 'a' - 'A';
  return a;
}
long long int sti(string a) {
  long long int k = 0;
  for (int i = 0; i < a.size(); ++i) {
    k *= 10;
    k += a[i] - '0';
  }
  return k;
}
string its(long long int k) {
  if (k == 0) return "0";
  string a;
  while (k) {
    a.push_back((k % 10) + '0');
    k /= 10;
  }
  reverse(a.begin(), a.end());
  return a;
}
int gcd(int a, int b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
template <class T, class K>
pair<T, K> mp(T a, K b) {
  return make_pair(a, b);
}
long long int mult(long long int a, long long int b) { return (a * b) % MOD; }
long long int pot(long long int n, long long int k) {
  if (k == 0) return 1;
  long long int a = pot(n, k / 2);
  a = mult(a, a);
  if (k % 2)
    return mult(a, n);
  else
    return a;
}
long long int divide(long long int a, long long int b) {
  return mult(a, pot(b, MOD - 2));
}
long long int sub(long long int a, long long int b) {
  return (a - b + MOD) % MOD;
}
long long int add(long long int a, long long int b) { return (a + b) % MOD; }
bool prime(long long int a) {
  if (a == 1) return 0;
  for (int i = 2; i <= round(sqrt(a)); ++i) {
    if (a % i == 0) return 0;
  }
  return 1;
}
pair<int, int> has(string x) {
  long long int h1 = 0, h2 = 0;
  x = to_lower(x);
  for (auto a : x) {
    h1 *= BASE;
    h1 += a - 'a';
    h1 %= MOD;
    h2 *= BASE;
    h2 += a - 'a';
    h2 %= MOD2;
  }
  return {h1, h2};
}
const int N = 300010;
int n, t;
int h[N];
int onn[N], ofn[N];
int onp[N], ofp[N];
bool on = 1;
int ma;
map<int, bool> ima;
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n >> t;
  ima[t] = 1;
  ima[0] = 1;
  for (int i = 0; i < n; ++i) {
    cin >> h[i];
    ima[h[i]] = 1;
    if (on) {
      onp[i] = onp[i - 1] + h[i] - h[i - 1];
      ofp[i] = ofp[i - 1];
    } else {
      onp[i] = onp[i - 1];
      ofp[i] = ofp[i - 1] + h[i] - h[i - 1];
    }
    on = !on;
  }
  if (on) {
    onp[n] = onp[n - 1] + t - h[n - 1];
    ofp[n] = ofp[n - 1];
  } else {
    onp[n] = onp[n - 1];
    ofp[n] = ofp[n - 1] + t - h[n - 1];
  }
  for (int i = 0; i < n; ++i) {
    ofn[i] = ofp[n] - ofp[i];
    onn[i] = onp[n] - onp[i];
  }
  ma = onp[n];
  on = 1;
  for (int i = 0; i < n; ++i) {
    if (on) {
      if (!ima[h[i] - 1] || !ima[h[i] + 1]) ma = max(ma, onp[i] - 1 + ofn[i]);
    } else {
      if (!ima[h[i] - 1] || !ima[h[i] + 1]) ma = max(ma, onp[i] + ofn[i] + 1);
    }
    on = !on;
  }
  cout << ma << en;
}
