#include <bits/stdc++.h>
using namespace std;
long double const PI = acosl(-1);
const int INF = 1E9 + 4;
const int MAXN = 5e5 + 123;
const long double EPS = 3e-16;
const long long MOD = 998244353;
long long a[MAXN];
long long f[2][MAXN];
void solve() {
  long long n, m;
  cin >> n >> m;
  for (int i = 1; i <= n; i++) cin >> a[i];
  a[n + 1] = m;
  for (int i = n; i >= 0; i--) {
    f[0][i] = f[1][i + 1];
    f[1][i] = f[0][i + 1] + (a[i + 1] - a[i]);
  }
  long long ans = f[1][0];
  for (int i = 0; i < n + 1; i++) {
    if (a[i + 1] - a[i] <= 1) continue;
    long long tp = (i & 1) ^ 1;
    long long sum = f[1][0] - f[tp][i];
    ans = max(ans, sum + (a[i + 1] - a[i] - 1) + f[tp][i + 1]);
  }
  cout << ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int t = 1;
  while (t--) solve();
  return 0;
}
