#include <bits/stdc++.h>
using namespace std;
vector<long long int> v, w;
int main() {
  long long int n, k;
  scanf("%lld%lld", &n, &k);
  v.push_back(0);
  for (long long int i = 0; i < n; i++) {
    long long int a;
    scanf("%lld", &a);
    v.push_back(a);
  }
  v.push_back(k);
  long long int sum = 0, sum2 = 0, mx = 0;
  for (long long int i = n; i >= 0; i--) {
    if (i % 2 == 0)
      sum += v[i + 1] - v[i];
    else
      sum2 += v[i + 1] - v[i];
    mx = max(mx, sum2 - sum);
  }
  if (mx == 0)
    cout << sum << endl;
  else
    cout << sum + mx - 1 << endl;
}
