#include <bits/stdc++.h>
using namespace std;
int a[100005];
int n;
int M;
int sum[100005][2];
int main() {
  scanf("%d%d", &n, &M);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  a[0] = 0, a[n + 1] = M;
  a[n + 2] = M;
  for (int i = 1; i <= n + 1; i++) {
    sum[i][1] = sum[i - 1][1];
    sum[i][0] = sum[i - 1][0];
    sum[i][i & 1] += a[i];
  }
  n++;
  int mx = sum[(n + 1) / 2 * 2 - 1][1] - sum[(n + 1) / 2 * 2 - 1][0];
  for (int i = 0; i <= n - 1; i++) {
    if (a[i + 1] - a[i] <= 1) continue;
    if (i & 1)
      mx = max(mx, sum[i][1] - sum[i][0] + a[i + 1] - (a[i] + 1) +
                       (sum[n / 2 * 2][0] - sum[i + 1][0]) -
                       (sum[n / 2 * 2][1] - sum[i + 1][1]));
    else
      mx = max(mx, (a[i + 1] - 1) - a[i] + sum[i - 1][1] - sum[i - 1][0] +
                       (sum[n / 2 * 2][0] - sum[i][0]) -
                       (sum[n / 2 * 2][1] - sum[i][1]));
  }
  printf("%d\n", mx);
}
