# Light It Up

Recently, you bought a brand new smart lamp with programming features. At first, you set up a schedule to the lamp. Every day it will turn power on at moment 00 and turn power off at moment MM. Moreover, the lamp allows you to set a program of switching its state (states are "lights on" and "lights off"). Unfortunately, some program is already installed into the lamp.

The lamp allows only good programs. Good program can be represented as a non-empty array aa, where 0<a1<a2<⋯<a|a|<M0<a1<a2<⋯<a|a|<M. All aiai must be integers. Of course, preinstalled program is a good program.

The lamp follows program aa in next manner: at moment 00 turns power and light on. Then at moment aiai the lamp flips its state to opposite (if it was lit, it turns off, and vice versa). The state of the lamp flips instantly: for example, if you turn the light off at moment 11 and then do nothing, the total time when the lamp is lit will be 11. Finally, at moment MM the lamp is turning its power off regardless of its state.

Since you are not among those people who read instructions, and you don't understand the language it's written in, you realize (after some testing) the only possible way to alter the preinstalled program. You can insert at most one element into the program aa, so it still should be a good program after alteration. Insertion can be done between any pair of consecutive elements of aa, or even at the begining or at the end of aa.

Find such a way to alter the program that the total time when the lamp is lit is maximum possible. Maybe you should leave program untouched. If the lamp is lit from xx till moment yy, then its lit for y−xy−x units of time. Segments of time when the lamp is lit are summed up.

Input

First line contains two space separated integers nn and MM (1≤n≤1051≤n≤105, 2≤M≤1092≤M≤109) — the length of program aa and the moment when power turns off.

Second line contains nn space separated integers a1,a2,…,ana1,a2,…,an (0<a1<a2<⋯<an<M0<a1<a2<⋯<an<M) — initially installed program aa.

Output

Print the only integer — maximum possible total time when the lamp is lit.

Examples

Input

3 10
4 6 7


Output

8


Input

2 12
1 10


Output

9


Input

2 7
3 4


Output

6


Note

In the first example, one of possible optimal solutions is to insert value x=3x=3 before a1a1, so program will be [3,4,6,7][3,4,6,7] and time of lamp being lit equals (3−0)+(6−4)+(10−7)=8(3−0)+(6−4)+(10−7)=8. Other possible solution is to insert x=5x=5 in appropriate place.

In the second example, there is only one optimal solution: to insert x=2x=2 between a1a1 and a2a2. Program will become [1,2,10][1,2,10], and answer will be (1−0)+(10−2)=9(1−0)+(10−2)=9.

In the third example, optimal answer is to leave program untouched, so answer will be (3−0)+(7−4)=6(3−0)+(7−4)=6.

### 题目大意：有一台灯，这个灯在时间为0时打开，m时关闭，在0到m这段时间内有n个时间点灯的状态会改变（即开变关，关变开），现在可以在  除n个时间点以外的点  选一个让灯的状态改变一次，求这个灯最大亮着的时间

#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <vector>
#define rush() int T;cin>>T;while(T--)
#define go(a) while(cin>>a)
#define ms(a,b) memset(a,b,sizeof a)
#define E 1e-8
using namespace std;
typedef long long ll;
const int inf=0x7f7f7f7f;
const int N=1e5+5;

int n,m,t;
int i,j,k;
ll a[N],b[N],c[N];
vector<int>ans;

int main()
{
cin.tie(0);istream::sync_with_stdio(false);
for(;cin>>n>>m;){
for(i=1;i<=n;i++) cin>>a[i];
a[n+1]=m;b[0]=0,c[0]=0,a[0]=0;
for(i=1;i<=n+1;i++){
if(i&1){//开灯时间结束
b[i]=b[i-1]+a[i]-a[i-1];
c[i]=c[i-1];
}
else{
b[i]=b[i-1];
c[i]=c[i-1]+a[i]-a[i-1];
}
}
ll ans=b[n+1];
for(i=0;i<=n+1;i++){
//在i时间点后面一秒插入一个开关
ans=max(ans,b[i]+c[n+1]-c[i]-1);
}
cout<<ans<<endl;
}
return 0;
}

06-28 375

08-06 114

07-13 1374

07-12 1615

12-30 714

07-17 1000

05-07 1318

07-30 1326

02-10 1342

06-22 3044

07-28 3262

07-13 3404

12-31 10

02-12 775

02-25 985

04-21 837

03-23 1205

08-26 1429

07-20 449

03-06 629

05-07 1486

04-14 59万+

03-13 15万+

03-04 13万+

03-08 2万+

04-25 6万+

03-10 13万+

03-10 18万+

03-12 11万+

03-13 11万+

03-18 9755

03-19 8万+

03-19 3万+

03-22 4万+

03-23 4万+

03-24 3万+

03-25 3万+

05-08 5万+

03-25 9万+

03-29 21万+

03-29 10万+

03-30 16万+

05-28 6082

05-28 1万+

04-02 1万+

04-02 5061

04-02 4万+

04-06 9726

04-06 7万+

04-09 8万+

04-09 2万+

05-17 8429

04-11 3万+

04-15 6万+

04-18 4万+

04-20 4万+

04-24 3万+

05-01 6386

05-03 1万+

05-16 5万+

05-06 1万+

05-07 2248

05-07 1万+

05-08 4万+

05-10 3246

05-14 6416

05-16 3548

05-16 1万+

05-17 5053

05-30 237

05-20 956

05-18 2210

05-18 8358

05-27 1353

05-18 3541

05-28 1194

05-19 1万+

05-19 1907

#### 程序员在家办公没显示屏，我被领导鄙视了

©️2019 CSDN 皮肤主题: 黑客帝国 设计师: 上身试试