#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int m, n, i, ans;
  cin >> m >> n;
  vector<long long int> v(m + 2, 0), on(m + 3, 0), off(m + 3, 0);
  for (i = 1; i <= m; i++) {
    cin >> v[i];
  }
  v[m + 1] = n;
  m += 2;
  for (i = 1; i < m; i++) {
    if (i & 1) {
      on[i] = on[i - 1] + abs(v[i] - v[i - 1]);
      off[i] = off[i - 1];
    } else {
      off[i] = off[i - 1] + abs(v[i] - v[i - 1]);
      on[i] = on[i - 1];
    }
  }
  ans = on[m - 1];
  for (i = 1; i < m; i++) {
    ans = max(ans, on[i] + (off[m - 1] - off[i] - 1));
  }
  cout << ans << endl;
}
