#include <bits/stdc++.h>
using namespace std;
void fs(long long int &number) {
  bool negative = false;
  register long long int c;
  number = 0;
  c = getchar();
  if (c == '-') {
    negative = true;
    c = getchar();
  }
  for (; (c > 47 && c < 58); c = getchar()) number = number * 10 + c - 48;
  if (negative) number *= -1;
}
long long int power(long long int a, long long int x) {
  a %= 1000000007;
  long long int res = 1;
  while (x > 0) {
    if (x & 1) res = res * a % 1000000007;
    a = a * a % 1000000007;
    x >>= 1;
  }
  return res;
}
long long int max(long long int a, long long int b) {
  if (a > b) {
    return a;
  } else {
    return b;
  }
}
long long int min(long long int a, long long int b) {
  if (a > b) {
    return b;
  } else {
    return a;
  }
}
long long int madd(long long int a, long long int b) {
  long long int ans;
  ans = (a % 1000000007 + b % 1000000007) % 1000000007;
  return ans;
}
long long int mmult(long long int a, long long int b) {
  long long int ans = 1;
  ans = ((a % 1000000007) * (b % 1000000007)) % 1000000007;
  return ans % 1000000007;
}
long long int modinverse(long long int a) { return power(a, 1000000007 - 2); }
signed main() {
  long long int n, m;
  cin >> n >> m;
  long long int a[n + 3];
  for (long long int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  a[0] = 0;
  a[n + 1] = m;
  long long int dp[n + 4];
  long long int dpe[n + 3], dpo[n + 3];
  for (long long int i = 0; i <= n + 2; i++) {
    dp[i] = 0;
    dpe[i] = 0;
    dpo[i] = 0;
  }
  for (long long int i = 1; i <= n + 1; i++) {
    dp[i] = a[i] - a[i - 1];
  }
  long long int sumo = 0, sume = 0;
  for (long long int i = n + 1; i >= 1; i--) {
    if (i % 2 == 1) {
      sumo += dp[i];
    } else {
      sume += dp[i];
    }
    dpe[i] = sume;
    dpo[i] = sumo;
  }
  long long int ans = sumo;
  for (long long int i = 1; i <= n + 1; i++) {
    if (i % 2 == 1) {
      ans = max(ans, dpe[i] + dp[i] - 1 + sumo - dpo[i]);
    } else {
      ans = max(ans, dpe[i + 1] + dp[i] - 1 + sumo - dpo[i]);
    }
  }
  cout << ans;
  cout << "\n";
}
