#include <bits/stdc++.h>
using namespace std;
int n, m, ans, sum, a[100010], l[100010], r[100010], sumy[100010];
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; ++i) scanf("%d", &a[i]);
  for (int i = 2; i <= n; ++i) l[i] = a[i - 1], r[i] = a[i];
  l[1] = 0, r[1] = a[1], l[n + 1] = a[n], r[n + 1] = m;
  for (int i = 1; i <= n + 1; i += 2) ans += r[i] - l[i];
  for (int i = n + 1; i; --i)
    sumy[i] = sumy[i + 1] + ((i & 1) == 0) * (r[i] - l[i]);
  for (int i = 1; i <= n + 1; ++i) {
    if (sum + r[i] - l[i] - 1 + sumy[i + 1] > ans)
      ans = sum + r[i] - l[i] - 1 + sumy[i + 1];
    if (i & 1) sum += r[i] - l[i];
  }
  printf("%d\n", ans);
  return 0;
}
