#include <bits/stdc++.h>
using namespace std;
int tim[100005], seq[100005];
long long tot;
int main() {
  int n, m;
  cin >> n >> m;
  seq[1] = 0;
  for (int i = 1; i <= n; i++) cin >> seq[i];
  seq[n + 1] = m;
  long long tp, ans = 0;
  long long oddsum = 0, totsum = 0, tmp, tmpans;
  for (int i = 1; i <= n + 1; i++) {
    tim[i] = seq[i] - seq[i - 1];
    if (i & 1) ans += tim[i];
    tot += tim[i];
  }
  tmpans = ans;
  for (int i = 1; i <= n + 1; i++) {
    if (i & 1) oddsum += tim[i];
    totsum += tim[i];
    tp = 0;
    tmp = tmpans - oddsum;
    tp = tot - totsum - tmp;
    ans = max(ans, tp - 1 + oddsum);
  }
  cout << ans << endl;
  return 0;
}
