#include <bits/stdc++.h>
using namespace std;
const int maxn = 100010;
int num[2], sum[2];
bool v[maxn];
int a[maxn], s[maxn];
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    s[i] = a[i] - a[i - 1];
    v[i] = v[i - 1] ^ 1;
    sum[v[i]] += s[i];
  }
  s[n + 1] = m - a[n];
  v[n + 1] = v[n] ^ 1;
  sum[v[n + 1]] += s[n + 1];
  int ans = 1;
  for (int i = n + 1; i >= 0; i--) {
    num[v[i]] += s[i];
    ans = max(ans, num[0] - num[1]);
  }
  printf("%d\n", sum[1] + (ans - 1));
}
