#include<iostream>
using namespace std;
void sort(int *a,int n)
{
	int i,j,t;
	for(i=n-1;i>=0;i--)
	{
		for(j=0;j<i;j++)
		{
			if(a[j]>a[j+1])
			{
				t=a[j];
				a[j]=a[j+1];
				a[j+1]=t;
			}
		}
	}
}

void print(int *a,int n)
{
	int i;
	for(i=0;i<n;i++)
	{
		cout<<a[i];
	}
}

int main()
{
	int i,t,n,k,m,j;
	double s=0,h;
	cin>>t;
	for(i=0;i<t;i++)
	{
		int a[101]={0};
		s=0;
		cin>>n>>m;
		for(j=0;j<n;j++)
		{
			cin>>a[j];
		}
		sort(a,n);
		for(j=0;j<n;j++)
		{
			for(k=j;k<n;k++)
			{
				h=k+1;
				s+=((double)a[k])/h;
			}
		}
		if(s==m)
		{
			cout<<"YES"<<endl;
		}
		if(s!=m)
		{
			cout<<"NO"<<endl;
		}
	}
	return 0;
}


#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <ctime>
using namespace std;

int main()
{
	int n;
	cin >> n;  //반복횟수

	for (int i = 0; i < n; i++)
	{
		int size, sum;
		cin >> size >> sum;
		int* arr = new int[size];
		for (int i = 0; i < size; i++)
		{
			cin >> arr[i];
			sum -= arr[i];
		}
		if (sum == 0)
			cout << "YES" << endl;
		else
			cout << "NO" << endl;
	}
	return 0;
}


#include <iostream>
#include <algorithm>
#include <vector>
#include <string>

using namespace std;

string reorder (int n, int m, vector<int> A)
{
	int sum=0;
	for (int i=0;i<n;i++)
	{
		sum+=A[i];
	}
	if (sum==m)
	return "YES";
	else
	return "NO";
}

int main()
{
	int T,n,m;
	vector<int> A;
	vector<string> result;
	cin>>T;
	result.resize(T);
	for (int i=0;i<T;i++)
	{
		cin>>n>>m;
		A.resize(n);
		for (int j=0;j<n;j++)
		cin>>A[j];
		sort (A.begin(),A.end());
		result[i]=reorder(n,m,A);
	}
	for (int i=0;i<T;i++)
	{
		cout<<result[i]<<endl;
	}
	return 0;
}


#include <bits/stdc++.h>
#include <vector>
#include <string>

using namespace std;

string reorder (int n, int m, vector<int> A)
{
	int sum=0;
	for (int i=0;i<n;i++)
	{
		sum+=A[i];
	}
	if (sum>m)
	return "NO";
	else
	return "YES";
}

int main()
{
	int T,n,m;
	vector<int> A;
	vector<string> result;
	cin>>T;
	result.resize(T);
	for (int i=0;i<T;i++)
	{
		cin>>n>>m;
		A.resize(n);
		for (int j=0;j<n;j++)
		cin>>A[j];
		sort (A.begin(),A.end());
		result[i]=reorder(n,m,A);
	}
	for (int i=0;i<T;i++)
	{
		cout<<result[i]<<endl;
	}
	return 0;
}


#include<iostream>
using namespace std;
int ans;int b;int x;int t;int num;
int main()
{
	cin>>t;
	while(t)
	{
	ans=0;
	cin>>num>>b;
	for(int i=1;i<=num;i++)
	{
		cin>>x;
		ans=ans+x;
	}
	if(ans==b)
	{cout<<"YES"<<endl;}
	else
	{cout<<"NO"<<endl;}
	t--;
	}
	return 0;
}


#include<stdio.h>
#include<string.h>
#include<math.h>
#include<map>
#include<queue>
#include<stack>
#include<string>
#include<stdlib.h>
#include<algorithm>
using namespace std;
typedef long long LL;
int n,a[110],m;
int main()
{
    int t;
    scanf("%d",&t);
    while(t--)
    {
        scanf("%d%d",&n,&m);
        for(int i=1; i<=n; i++)
            scanf("%d",&a[i]);
       int sum=0;
        for(int i=1;i<=n;i++)
      		sum+=a[i];
		if(sum==m)
			printf("YES\n");
		else
			printf("NO\n");
    }
    return 0;
}


#include<stdio.h>
#include<string.h>
#include<math.h>
#include<map>
#include<queue>
#include<stack>
#include<string>
#include<stdlib.h>
#include<algorithm>
using namespace std;
typedef long long LL;
int n,a[110],m;
int main()
{
    int t;
    scanf("%d",&t);
    while(t--)
    {
        scanf("%d%d",&n,&m);
        for(int i=1; i<=n; i++)
            scanf("%d",&a[i]);
        sort(a+1,a+1+n);
        double sum=0;
        for(int i=1;i<=n;i++)
        {
        	for(int j=i;j<=n;j++)
        	{
        		sum+=(a[j]*1.0)/(j+0.0);
			}
		}
		int k=(int)sum;
		if(k==m)
			printf("YES\n");
		else
			printf("NO\n");

    }
    return 0;
}


#include <iostream>

using namespace std;

int main()
{
    int t, n, m, x, s = 0, i, j;
    cin >> t;
    for(i = 1; i <= t; i++)
    {
        cin >> n >> m;
        for(j = 1; j <= n; j++)
        {
            cin >> x;
            s += x;
        }
        if(s == m)
            cout << "YES" << '\n';
        else
            cout << "NO" << '\n';
    }
    return 0;
}


#include <iostream>

using namespace std;

int main()
{
    int t, n, m, x, s, i, j;
    cin >> t;
    for(i = 1; i <= t; i++)
    {
        cin >> n >> m;
        s = 0
        for(j = 1; j <= n; j++)
        {
            cin >> x;
            s += x;
        }
        if(s == m)
            cout << "YES" << '\n';
        else
            cout << "NO" << '\n';
    }
    return 0;
}


#include <iostream>

using namespace std;

int main()
{
    int t, n, m, x, s, i, j;
    cin >> t;
    for(i = 1; i <= t; i++)
    {
        cin >> n >> m;
        s = 0;
        for(j = 1; j <= n; j++)
        {
            cin >> x;
            s += x;
        }
        if(s == m)
            cout << "YES" << '\n';
        else
            cout << "NO" << '\n';
    }
    return 0;
}


#include <iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<utility>
#include<cstdio>
#include<cstring>
#include<stack>
#include<queue>
#include<map>
#include<iomanip>
#define vii vector< pair<int,int> >
#define vi vector<float>
#define INF 1000000007
#define MS 1000001
#define endl "\n"
#define ff first
#define ss second
#define lli long long int
#define ulli unsigned long long int
using namespace std;
int main() {
 ios_base::sync_with_stdio(false);
    cin.tie(NULL);
   int t;
   cin>>t;
   while(t--){
     long double n,m;
     cin>>n>>m;
     long double ans=0;
     vi v(n+1);
     for(int i=1; i<=n; i++)
      cin>>v[i];
    cout<<fixed<<setprecision(12);
     for(float i=1; i<=n; i++){
       for(float j=i; j<=n; j++){
         ans+=v[j]/j;
        // cout<<ans<<endl;
       }
     }
   //  cout<<ans<<endl;
     lli a=ans,b=m;
     if(a==b)
     cout<<"YES";
     else cout<<"NO";
     cout<<endl;
   }
}


#include <iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<utility>
#include<cstdio>
#include<cstring>
#include<stack>
#include<queue>
#include<map>
#include<iomanip>
#define vii vector< pair<int,int> >
#define vi vector<double>
#define INF 1000000007
#define MS 1000001
#define endl "\n"
#define ff first
#define ss second
#define lli long long int
#define ulli unsigned long long int
using namespace std;
int main() {
 ios_base::sync_with_stdio(false);
    cin.tie(NULL);
   int t;
   cin>>t;
   while(t--){
     long double n,m;
     cin>>n>>m;
     long double ans=0;
     vi v(n+1);
     for(int i=1; i<=n; i++)
      cin>>v[i],ans+=v[i];
   /* cout<<fixed<<setprecision();
     for(int i=1; i<=n; i++){
       for(int j=i; j<=n; j++){
         ans+=v[j]/j;
        // cout<<ans<<endl;
       }
     }
   //  cout<<ans<<endl;
     lli a=ans,b=m;*/
     if(ans==m)
     cout<<"YES";
     else cout<<"NO";
     cout<<endl;
   }
}


#include <iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<utility>
#include<cstdio>
#include<cstring>
#include<stack>
#include<queue>
#include<map>
#include<iomanip>
#define vii vector< pair<int,int> >
#define vi vector<float>
#define INF 1000000007
#define MS 1000001
#define endl "\n"
#define ff first
#define ss second
#define lli long long int
#define ulli unsigned long long int
using namespace std;
int main() {
 ios_base::sync_with_stdio(false);
    cin.tie(NULL);
   int t;
   cin>>t;
   while(t--){
     double n,m;
     cin>>n>>m;
     double ans=0;
     vi v(n+1);
     for(int i=1; i<=n; i++)
      cin>>v[i];
     for(float i=1; i<=n; i++){
       for(float j=i; j<=n; j++){
         ans+=v[j]/j;
        // cout<<ans<<endl;
       }
     }
   //  cout<<ans<<endl;
     if(int(ans)==int(m))
     cout<<"YES";
     else cout<<"NO";
     cout<<endl;
   }
}


#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	int t;
	cin >> t;
	while (t--) {
		int n, m;
		cin >> n >> m;
		int sum = 0, num;
		for (int i = 0; i < n; i++) {
			cin >> num;
			sum += num;
		}
		if (sum == m) {
			cout << "YES" << '\n';
		}
		else {
			cout << "NO" << '\n';
		}
	}
	return 0;
}


#include<iostream>
using namespace std;
int main()
{
	int n,m,sum;
	int i;
	cin>>n;
	while(n--)
	{
		int suml=0;
		cin>>m>>sum;
		int A[m];
		for(i=0;i<m&&cin>>A[i];i++);
		for(i=0;i<m;i++)
		{
			suml+=A[i];
		}
		if(suml==sum)
		{
			cout<<"YES"<<endl;
		}
		if(suml!=sum)
		{
			cout<<"NO"<<endl;
		}
	}
}


#include<iostream>
using namespace std;
int main()
{
	int n,m,sum;
	int i;
	cin>>n;
	while(n--)
	{
		int suml=0;
		cin>>m>>sum;
		int A[105];
		for(i=0;i<m&&cin>>A[i];i++);
		for(i=0;i<m;i++)
		{
			suml+=A[i];
		}
		if(suml==sum)
		{
			cout<<"YES"<<endl;
		}
		if(suml!=sum)
		{
			cout<<"NO"<<endl;
		}
	}
}


#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<deque>
#include<map>
#include<unordered_map>
#include<stack>
#define Fori(a,n) for(long long i=a;i<n;i++)
#define Forj(a,n) for(long long j=a;j<n;j++)
#define Fork(a,n) for(long long k=a;k<n;k++)
using namespace std;
void main()
{
		long long size,len,sum;
		cin >> size;
		Fori(0,size){
		cin >> len >> sum;
		vector<long double>vec(len);
		Forj(0,len){
		cin >> vec[j];
		}

		bool found = false;
		sort(vec.begin(), vec.end());
		do{
			long double sm = 0;
			Fork(0,len){
				sm += (long double)(vec[k] / (k + 1)) * (k + 1);
			}
			if (sm == sum){
				cout << "YES" << endl;
				found = true;
				break;
			}
		} while (next_permutation(vec.begin(), vec.end()));

			if (!found){
				cout << "NO" << endl;
			}
		}

/*	vector<long long>vec{ 2,1,5 };
	sort(vec.begin(), vec.end());
	do{
		long double sm = 0;
		Fork(0, 3){
			cout << vec[k] <<" ";
		}
		cout << endl;
	} while (next_permutation(vec.begin(), vec.end()));*/

}


#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<deque>
#include<map>
#include<unordered_map>
#include<stack>
#define Fori(a,n) for(long long i=a;i<n;i++)
#define Forj(a,n) for(long long j=a;j<n;j++)
#define Fork(a,n) for(long long k=a;k<n;k++)
using namespace std;
void main()
{
		long long size,len,sum,sm,num;
		cin >> size;
		Fori(0,size){
			cin >> len >> sum;
			sm = 0;
			Forj(0,len){
				cin >> num;
				sm += num;
			}
			if (sm == sum)
				cout << "YES" << endl;
			else
				cout << "NO" << endl;
		}

/*	vector<long long>vec{ 2,1,5 };
	sort(vec.begin(), vec.end());
	do{
		long double sm = 0;
		Fork(0, 3){
			cout << vec[k] <<" ";
		}
		cout << endl;
	} while (next_permutation(vec.begin(), vec.end()));*/

}


#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main() {
    ll n, m, i, j, t, w, k;
    while (cin >> k) {
            while(k--){
                cin >> n >> m;
                for(i=t=0;i<n;i++)cin>>j,t+=j;
                cout<<(m==t?"YES":"NO")<<endl;
            }
    }
}


#include <iostream>
#define ll long long
using namespace std;
int main() {
    ll n, m, i, j, t, w, k;
    while (cin >> k) {
            while(k--){
                cin >> n >> m;
                for(i=t=0;i<n;i++)cin>>j,t+=j;
                cout<<(m==t?"YES":"NO")<<endl;
            }
    }
}


#include<iostream>
uisng namespace std;
#include<vector>
int main()
{
    vector<int>A;
    int a;
    cin >> a;
    while (a--)
    {
        int b;
        cin >> b;
        int sum;
        cin >> sum;
        int c;
        while (b--)
        {
            cin >> c;
            A.push_back(c);
        }
        c = 0;
        for (int i = 0; i < A.size(); i++)
        {
            c = A[i] + c;
       }
        if (c == sum)cout << "YES" << endl;
        else cout << "NO" << endl;

    }

}


#include<iostream>
using namespace std;
#include<vector>
int main()
{

    int a;
    cin >> a;
    while (a--)
    {
        vector<int>A;
        int b;
        cin >> b;
        int sum;
        cin >> sum;
        int c;
        while (b--)
        {
            cin >> c;
            A.push_back(c);
        }
        c = 0;
        for (int i = 0; i < A.size(); i++)
        {
            c = A[i] + c;
       }
        if (c == sum)cout << "YES" << endl;
        else cout << "NO" << endl;

    }

}


#include<iostream>
using namespace std;
#include<vector>
int main()
{
    vector<int>A;
    int a;
    cin >> a;
    while (a--)
    {
        int b;
        cin >> b;
        int sum;
        cin >> sum;
        int c;
        while (b--)
        {
            cin >> c;
            A.push_back(c);
        }
        c = 0;
        for (int i = 0; i < A.size(); i++)
        {
            c = A[i] + c;
       }
        if (c == sum)cout << "YES" << endl;
        else cout << "NO" << endl;

    }

}


#include <iostream>
#include <algorithm>
using namespace std;

int main()
{
	int t;
	cin>>t;
	while(t--){
		long long n,m;
		cin>>n>>m;
		long long sum=0;
		for(long long i=0;i<n;i++){
             int x;
			 cin>>x;
			 sum+=x;
		}
		if(sum==m){
			cout<<"YES"<<endl;
		}
		else{
			cout<<"NO"<<endl;
		}

	}
	return 0;
}


#include<iostream>
#include<cmath>
#include<map>
#include<string.h>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<queue>
#include<iomanip>
#include<string>
using namespace std;
typedef long long ll;
const int MAXN = 1e5 + 5;
int n, m;
int dp[5005][5005] = { 0 };
int main() {
    int t;
    cin >> t;
    while (t--) {
        int n, m;
        cin >> n >> m;
        int s = 0;
        for (int i = 1;i <= n;i++) {
            int a;
            cin >> a;
            s += a;
        }
        if (s == m)cout << "YES" << endl;
        else cout << "NO" << endl;
    }

}


# include <iostream>
# include <vector>

int sum(std::vector<int> a) {
	int b = 0;
	for (int i = 0; i < a.size(); i++) {
		b += a[i];
	}
	return b;
}

int main() {
	int a, b, c, e;
	std::vector<int> d;
	std::cin >> a;
	for (int i = 0; i < a; i++) {
		std::cin >> b >> e;
		for (int j = 0; j < b; j++) {
			std::cin >> c;
			d.push_back(c);
		}
		if (sum(d) != e) std::cout << "NO\n";
		else std::cout << "YES\n";
		d.clear();
	}
	return 0;
}


#include<iostream>
#include<vector>
#include<cstdio>

using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    cin>>t;
    while(t--){
        int n,m;
        cin>>n>>m;

        int sum =0;
        for(int i=0;i<n ;i++){
            int x;
             cin>>x;
             sum += x;

        }
        if(sum==m) cout<<"YES"<<endl;
        else cout<<"NO"<<endl;

    }
  return 0;
}


/*
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XX   XXXXXXXXX  XXXXXXXXXXXXXXXX  XXXXXXXXXXXXXXXXXXXXXXXXX X
X XXX XX   XXXX XXXX    X XXX XXX XXXX   XXXX XXXX   XXXXXX X
X XXXXXXXXX XXX XXX XXXXX XXX XXX XXXXXXX XX   XX XXX XX    X
X XXXXX     XXX XXX XXXXX XXX XXX XXX     XXX XXX     X XXX X
X XXX X XXX XXX XXX XXXXX XXX XXX XXX XXX XXX XXX XXXXX XXX X
XX   XXX    XX   XXX    XX    XX   XXX    XXX  XXX    XX    X
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXX     XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXX XXXXX   XXXX   XX  X XXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXX XXXX XXX XXXXXX X X X XXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXX XXXX     XX     X X X XXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXX XXXX XXXXXX XXX X XXX XXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXX XXXXX    XXX    X XXX XXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
*/

#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <iomanip>
#include <chrono>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <array>
#include <set>
#include <list>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <unordered_map>
#include <map>
#include <iterator>
#include <cstring>
using namespace std;

#define loop(i,start,end) for(auto i = start; i < end; i++)
#define loopi(end) loop(i,0,end)
#define loopj(end) loop(j,0,end)
#define loopk(end) loop(k,0,end)
#define get_i(n) int n; cin >> n;
#define get_ch(n) char x; cin >> x;
#define get_doub(n) double n; cin >> n;
#define pb push_back
#define ll long long
#define pii pair<int,int>
#define pll pair<ll, ll>
#define vb vector<bool>
#define vi vector<int>
#define vpi vector<pii>
#define vll vector<long long>
#define vvi vector<vector<int>>
#define vvll vector<vector<long long>>
#define all(a) (a).begin(), (a).end()
const long long modulo = 1e9 + 7;
const ll INF = 1e18;
const int inf = 2e9;
const double PI = 3.141592653589793238463;

//#define FILE "scavhunt"
#define FAST_IO
#define FSOL
//#define DEBUG

#ifdef FSOL
void solve() {
	int q; cin >> q;
	while(q--) {
		int n, m, sum = 0, x; cin >> n >> m;
		loopi(n)
			cin >> x, sum += x;
		cout << (m == sum ? "YES\n" : "NO\n");
	}
}

#else
void solve() {

}
#endif

int main() {
#ifdef FAST_IO
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
#endif
#ifdef DEBUG
	freopen("debug.in", "r", stdin);
	freopen("debug.txt", "w", stdout);
	auto timestamp = std::chrono::system_clock::now();
#else
#ifdef FILE
	freopen(FILE".in", "r", stdin);
	freopen(FILE".out", "w", stdout);
#endif
#endif
	solve();
#ifdef DEBUG
	cout << endl << "Time elapsed: " << chrono::duration_cast<chrono::milliseconds>(std::chrono::system_clock::now() - timestamp).count() << " ms" << endl;
#endif
	return 0;
}


#include <iostream>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <cstdio>
#include <queue>
#include <deque>

using namespace std;

//ifstream cin("meetings.in");
//ofstream cout("meetings.out");

#define x first
#define y second
#define mp make_pair
#define endl '\n'
#define rall(a) a.rbegin(), a.rend()

typedef long long li;
typedef double ld;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef pair<pii, pii> ppp;
typedef pair<pll, pll> ppl;

const int LIM = 1e5;
const int INF = 1e9;
const long long INF64 = 1e18;
const int MOD = INF + 7;
const double EPS = 1e-9;

int main() {
	ios_base::sync_with_stdio(false);

	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);

	int t;

	cin >> t;

	while (t--) {

		int n, m;

		cin >> n >> m;

		vector<int> a(n);

		int sum = 0;

		for (int i = 0; i < n; i++) {
			cin >> a[i];

			sum += a[i];
		}

		if (sum == m)
			cout << "YES";
		else
			cout << "NO";

		cout << endl;
	}
	return 0;
}


#include <iostream>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <cstdio>
#include <queue>
#include <deque>

using namespace std;

//ifstream cin("meetings.in");
//ofstream cout("meetings.out");

#define x first
#define y second
#define mp make_pair
#define endl '\n'
#define rall(a) a.rbegin(), a.rend()

typedef long long li;
typedef double ld;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef pair<pii, pii> ppp;
typedef pair<pll, pll> ppl;

const int LIM = 1e5;
const int INF = 1e9;
const long long INF64 = 1e18;
const int MOD = INF + 7;
const double EPS = 1e-9;

int main() {
	ios_base::sync_with_stdio(false);

	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);

	int t;

	cin >> t;

	while (t--) {

		int n, m;

		cin >> n >> m;

		vector<int> a(n);

		int sum = 0;

		for (int i = 0; i < n; i++) {
			cin >> a[i];

			sum += a[i];
		}

		if (sum == m)
			cout << "YES";
		else
			cout << "NO";
	}
	return 0;
}


#include <algorithm>
#include <iostream>
#include <unordered_map>
#include <map>
#include <set>
#include <deque>
#include <list>
#include <unordered_set>
#include <fstream>
#include <string>
#include <vector>
#include <sstream>
#include <array>
#include <queue>
#include <stack>

#define lli long long int
#define ld long double
#define ls long string
using namespace std;
using ll = long long;

//check for outofbounds

int main() {
	ofstream fout("paint.out");
	ifstream fin("paint.in");

	int t; cin >> t;
	for (int i = 0; i < t; i++) {
		int n, m; cin >> n >> m;
		vector<int>v(n);
		for (int j = 0; j < n; j++) {
			cin >> v[j];
		}
		int sum = 0;
		for (auto x : v) {
			sum += x;
		}
		if (sum == m) {
			cout << "YES" << endl;
		}
		else
			cout << "NO" << endl;

	}

	return 0;
	//fout.close();
}

/*
int bs(vector<int>v, int x) {
	int l = 0;
	int r = v.size() - 1;

	while (l <= r) {
		int m = (l + r) / 2;
		if (v[m] == x)
			return m;
		else if (v[m] > x)
			r = m - 1;
		else
			l = m + 1;
	}
	return -1;
}

*/


#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include<numeric>
#include<cmath>

using namespace std;

int main()
{
	int t; cin >> t;
	for (int i = 0; i < t; ++i)
	{
		int n, m, a; cin >> n >> m;
		vector<int> vec;
		for (int j = 0; j < n; ++j)
		{
			cin >> a;
			vec.push_back(a);
		}
		int sum = accumulate(vec.begin(), vec.end(), 0);
		if (m == sum)
		{
			cout << "YES" << endl;
		}
		else
		{
			cout << "NO" << endl;
		}
	}

	return 0;
}


// Edu.cpp : Этот файл содержит функцию "main". Здесь начинается и заканчивается выполнение программы.
//

#include <iostream>
#include <vector>
#include <string>
using namespace std;

void solution() {
    int n; cin >> n;
    int m; cin >> m;
    long long sum = 0;
    int input;
    for (int i = 0; i < n; i++) {
        cin >> input;
        sum += input;
        if(sum>m){cout << "NO" << endl;return;}
    }
    if (sum == m) { cout << "YES" << endl; }
    else { cout << "NO" << endl; }

}

int main()
{

    int n; cin >> n;
    for (int i = 0; i < n; i++) {
        solution();
    }
    //solution();
}


// Edu.cpp : Этот файл содержит функцию "main". Здесь начинается и заканчивается выполнение программы.
//

#include <iostream>
#include <vector>
#include <string>
using namespace std;

void solution() {
    int n; cin >> n;
    int m; cin >> m;
    int sum = 0;
    int input;
    for (int i = 0; i < n; i++) {
        cin >> input;
        sum += input;
    }
    if (sum == m) { cout << "YES" << endl; }
    else { cout << "NO" << endl; }

}

int main()
{

    int n; cin >> n;
    for (int i = 0; i < n; i++) {
        solution();
    }
    //solution();
}


#include<iostream>
using namespace std;
int main(){
	int t;
	cin >> t;
	while(t--){
		long long n,m;
		cin >>n >>m;
		long long sum=0;
		for(int i=0;i<n;i++){
			long long a;
			cin >> a;
			sum += a;
		}
		if(sum == m) cout << "YES" << endl;
		else cout << "NO" << endl;
	}
	return 0;
}


#include<iostream>
using namespace std;

int main()
{
    bool answ[1000];
    int t, n, m, s, p;

    cin >> t;
    for(int i = 0; i < t; i++)
    {
        s = 0;
        cin >> n >> m;
        for(int j = 0; j < n; j++)
        {
            cin >> p;
            s+=p;
        }
        if(s==m) answ[i] = true;
        else answ[i] = false;
    }
    for(int i = 0; i < t; i++)
        if(answ[i]) cout << "YES\n";
        else cout << "NO\n";
    return 0;
}


#include <iostream>
#include<string>
using namespace std;

int main(){
    int x;
   int n;
   int m;
   int sum;
   int t;
   cin>>t;
 for(t;t>0;t--){
     cin>>n;
     cin>>m;
     sum=0;
     for(;n>0;n--)
     {
     cin>>x;
     sum+=x;

     }
     if(sum==m) cout<<"YES"<<endl;
     else cout<<"NO"<<endl;
 }

}


#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<cstring>
#include<string>
using namespace std;

int main(){
	int t;
	cin>>t;
	while(t--){
		int n,m;
		cin>>n>>m;
		int sum=0;
		while(n--){
			int x;
			cin>>x;
			sum+=x;
		}
		puts(sum==m?"YES":"NO");
	}
	return 0;
}


#include<iostream>
using namespace std;
int main(){
	int i,s,k,j,m,n,t;
	cin>>t;

	for(i=0;i<t;i++){
		cin>>n;
	    s=0;
	    cin>>m;
		for(j=0;j<n;j++){
			cin>>k;
			s=s+k;
		}
		if(s==m){
			cout<<"YES\n";
		}
		else{
			cout<<"NO\n";
		}
	}
	return 0;
}


#include<iostream>
using namespace std;
int main(){
	int i,s,j,m,n,t;
	cin>>t;
	int a[n];

	for(i=0;i<t;i++){
		cin>>n;
	    s=0;
	    cin>>m;
		for(j=0;j<n;j++){
			cin>>a[i];
			s=s+a[i];
		}
		if(s==m){
			cout<<"YES\n";
		}
		else{
			cout<<"NO\n";
		}
	}
	return 0;
}


#include <iostream>

using namespace std;
void solve(){
    int n;
    long long k;
    long long sum=0;
    int value;
    cin>>n>>k;
    for(int i=0;i<n;i++){
            cin>>value;
        sum+=value;
    }
    if(sum==k){
        cout<<"YES"<<endl;
    }else{
        cout<<"NO"<<endl;
    }
}
int main()
{
    int t;
    cin>>t;
    while(t--){
        solve();
    }
}


#include<stdio.h>
int main()
{
	int t,m,n,sum=0,i,a[101];
	scanf("%d",&t);
	while(t--)
	{
		scanf("%d %d",&n,&m);
		for (i=1;i<=n;i++)
			{
				scanf("%d",&a[i]);
				sum+=a[i];
			}
		if (sum!=m)
			printf("NO\n");
			else printf("YES\n");
	}
	return 0;
 }


#include<stdio.h>
int main()
{
	int t,m,n,sum=0,i,a[101];
	scanf("%d",&t);
	while(t--)
	{
		sum=0;
		scanf("%d %d",&n,&m);
		for (i=1;i<=n;i++)
			{
				scanf("%d",&a[i]);
				sum+=a[i];
			}
		if (sum!=m)
			printf("NO\n");
		else printf("YES\n");
	}
	return 0;
 }


#include "iostream"
using namespace std;
#define REP(i,a,b) for (int i=a; i<b; i++)
typedef long long ll;

int main()
{
	int n; ll m;
	int t; cin>>t;
	bool *b= new bool[t];
	REP(i,0,t)
	{
		cin>>n>>m;
	    ll *a= new ll[n];
		REP(j,0,n)
		{
			cin>>a[j];
			m-=a[j];
		}
		if (m==0) {b[i]=true;} else{b[i]=false;}
		delete[] a;
	}
	REP(i,0,t)
	{
		if (b[i]==true) {cout<<"YES"<<endl;} else{cout<<"NO"<<endl;}
	}
	return 0;
}


#include<iostream>
using namespace std;
int main()
{
	int j,i,n,t,a[100];
	cin>>t;
	while(t--)
	{
		int k,sum=0;
		cin>>n>>k;
		for(i=0;i<n;i++)
		{
			cin>>a[i];
			sum=sum+a[i];
		}
		if(sum==k)
		cout<<"YES"<<endl;
		else
		cout<<"NO"<<endl;
	}
}


#include<iostream>
using namespace std;
int main()
{
	int j,i,n,t,a[100];
	cin>>t;
	while(t--)
	{
		int k,sum=0;
		cin>>n>>k;
		for(i=0;i<n;i++)
		{
			cin>>a[i];
			sum=sum+a[i];
		}
		if(sum==k)
		cout<<"YES";
		else
		cout<<"NO";
	}
}


#include<iostream>
using namespace std;
int main(){
    int t;
    cin>>t;
    while(t--){
        int n,a[101],m;
        cin>>n>>m;
        int sum=0;
        for(int i=1;i<=n;i++){
            cin>>a[i];
            sum=sum+a[i];
        }
    if(sum==m){
        cout<<"YES"<<endl;
    }else
        cout<<"NO"<<endl;
    }
    return 0;
}


#include<stdio.h>
int main()
{
    int i,t,n,m,a[101],s;
    scanf("%d",&t);
    while(t--)
    {
        scanf("%d %d",&n,&m);
        for(i=0,s=0;i<n;i++)
        {
            scanf("%d",&a[i]);
            s+=a[i];
        }
        if(s==m)
            printf("YES\n");
        else
            printf("NO\n");
    }
    return 0;
}


#include <cstdlib>
#include <iostream>
#include <string>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <map>
#include <math.h>

using namespace std;

int main()
{
	int q;
	cin>>q;
	while(q--){
		int y,x,m,iSum=0;
		cin >>y>>m;
		for(int i=0;i<y;i++){
			cin >>x;
			iSum+=x;
		}
		if(iSum==m){
			cout<<"YES"<<endl;
		}
		else {
            cout<<"NO"<<endl;
        }
	}
	return 0;
}


#include <cstdlib>
#include <iostream>
#include <string>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <map>
#include <math.h>

using namespace std;

int main()
{
	int q;
	cin>>q;
	while(q--){
		int x,m,iSum=0;
		cin >>x>>m;
		for(int i=0;i<x;i++){
			cin >>x;
			iSum+=x;
		}
		if(iSum==m){
			cout<<"YES"<<endl;
		}
		else {
            cout<<"NO"<<endl;
        }
	}
	return 0;
}


#include <cstdlib>
#include <iostream>
#include <string>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <map>
#include <math.h>

using namespace std;

int main()
{
	int q;
	cin>>q;
	while(q--){
		int x,m,iSum=0;
		cin >>x>>m;
		for(int i=0;i<x;i++){
			cin >>x;
			iSum+=x;
		}
		if(iSum==x){
			cout<<"YES"<<endl;
		}
		else {
            cout<<"NO"<<endl;
        }
	}
	return 0;
}


#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <cstdlib>

using namespace std;
typedef long long ll;

ll T,n,m;
int main()
{
	scanf("%lld",&T);
	while(T--)
	{
		scanf("%lld%lld",&n,&m);
		ll sum=0;
		for(ll i=1;i<=n;i++)
		{
			ll temp;
			scanf("%lld",&temp);
			sum+=temp;
		}
		if(sum==m)
			printf("YES\n");
		else
			printf("NO\n");
	}

	return 0;
}


#include <cstring>
#include <algorithm>
#include <iostream>

using namespace std;

typedef long long ll;
const int inf = 0x3f3f3f;
typedef pair<int, int> PII;

const int N = 2000 + 10;
const int mod = 1e9 + 7;

int n, m, t, x, pos;
int s[N];
char str[N];

int main()
{
	int t, sum;
	cin >> t;
	while (t--)
	{
		scanf("%d %d", &n, &sum);
		for (int i = 1; i <= n; i++)
		{
			scanf("%d", &s[i]);
			sum -= s[i];
		}
		if (sum == 0) printf("YES\n");
		else printf("NO\n");
	}
	return 0;
}


t = int(input())

while t>0:
    t = t-1
    n,m = map(int,input().split())
    arr = list(map(int,input().split()))
    if (sum(arr) == m):
        print("Yes")
    else:
        print("No")


t = int(input())

while i<t:
    t = t-1
    n,m = map(int,input().split())
    arr = list(map(int,input().split()))


t = int(input())

while t>0:
    t = t-1
    n,m = map(int,input().split())
    arr = list(map(int,input().split()))
    if (sum(arr) == m):
        print("Yes")
    else:
        print("No")

    t = t-1


t = int(intput())

while i<t:
    t = t-1
    n,m = map(int,input().split())
    arr = list(map(int,input().split()))

if sum(arr) == m:
    print("Yes")
else:
    print("No")


t = int(input())

while t>0
    t = t-1
    n,m = map(int,input().split())
    arr = list(map(int,input().split()))
    if (sum(arr) == m):
        print("Yes")
    else:
        print("No")

    t = t-1


try:
    t=int(input())
    for i in range(0,t):
        s=0
        n,m=list(map(int,input().split(" ")))
        x=list(map(int,input().split(" ")))
        for j in range(0,len(x)):
            for i in range(j,len(x)):
                s+=x[i]/(i+1)
                s=round(s)
        if s==m:
            print("YES")
        else:
            print("NO")
except:
    pass


try:
    t=int(input())
    for i in range(0,t):
        n,m=list(map(int,input().split(" ")))
        x=list(map(int,input().split(" ")))
        s=0
        for j in range(0,len(x)):
            for i in range(j,len(x)):
                s+=x[i]/i
        if s==m:
            print("YES")
        else:
            print("NO")
except:
    pass


try:
    from fractions import Fraction
    t=int(input())
    for i in range(0,t):
        s=0
        n,m=list(map(int,input().split(" ")))
        x=list(map(int,input().split(" ")))
        for j in range(0,len(x)):
            for i in range(j,len(x)):
                s+=Fraction(x[i],(i+1))
        if s==m:
            print("YES")
        else:
            print("NO")
except:
    pass


try:
    from fractions import Fraction
    t=int(input())
    for i in range(0,t):
        s=0
        n,m=list(map(int,input().split(" ")))
        x=list(map(int,input().split(" ")))
        s=sum(x)
        if s==m:
            print("YES")
        else:
            print("NO")
except:
    pass


t = int(input())
for time in range(t):
    lst = []
    a = []
    num = input()
    lst = num.split()
    n = (lst[0])
    m = int(lst[1])

    number = input()
    a = number.split()

    sumation = 0
    for num in a:
        mynum = int(num)
        sumation += mynum

    if (sumation == m):
        print("YES")
    else:
        print("NO")


a = []
t = int(input())
lst = []

for ask in range(2):
    lst.append(int(input()))
n = lst[0]
m = lst[1]
for ask in range(n):
    number = int(input())
    a.append(number)

sumation = 0
for num in a:
    sumation += num

if (sumation == m):
    print("YES")
else:
    print("NO")


t=int(input())
while(t>0):
    n,m=map(int,input().split())
    l=[int(x) for x in input().split()]
    if 0 in l:
        print("NO")
    else:
        print("YES")
    t=t-1


#include<iostream>
#include<vector>
#include<stdlib.h>
#include<time.h>
#include<math.h>
#include<string.h>
#include<algorithm>

int calculate(std::vector<int>a){
 int sum=0;
 for(int i=1; i<a.size(); i+=2){
    sum+=(a[i]-a[i-1]);
 }
 return sum;
}

int main(void){
 int n,m,j;
 int w;
 int max=-1;
 int sum=0;
 int size=0;
 std::vector<int> a;

 std::cin>>n>>m;
 a.push_back(0);

 for(int i=0; i<n; i++){
  std::cin>>w;
  a.push_back(w);
 }
 a.push_back(m);

 size=a.size();
 max=std::max(max,calculate(a));
 for(int i=0; i<size-1; i++){
   if(a[i]+1!=a[i+1]){
    a.insert(a.begin()+(i+1),a[i]+1);
    max=std::max(max,calculate(a));
    a.erase(a.begin()+i+1);
   }
 }
 for(int i=1; i<size; i++){
  if(a[i]-1!=a[i-1]){
   a.insert(a.begin()+i,a[i]-1);
   max=std::max(max,calculate(a));
   a.erase(a.begin()+i);
  }
 }
 std::cout<<max<<std::endl;

}


#include<iostream>
#include<vector>
#include<stdlib.h>
#include<time.h>
#include<math.h>
#include<string.h>
#include<algorithm>

long long int calculate(std::vector<int>a){
 long long int sum=0;
 for(int i=1; i<a.size(); i+=2){
    sum+=(a[i]-a[i-1]);
 }
 return sum;
}

int main(void){
 int n,m;
 int w;
 long long int max=-1;
 int size=0;
 std::vector<int> a;

 std::cin>>n>>m;
 a.push_back(0);

 for(int i=0; i<n; i++){
  std::cin>>w;
  a.push_back(w);
 }
 a.push_back(m);
 size=a.size();
 max=std::max(max,calculate(a));
 for(int i=0; i<size-1; i++){
   if(a[i]+1!=a[i+1]){
    a.insert(a.begin()+(i+1),a[i]+1);
    max=std::max(max,calculate(a));
    a.erase(a.begin()+i+1);
   }
 }
 for(int i=1; i<size; i++){
  if(a[i]-1!=a[i-1]){
   a.insert(a.begin()+i,a[i]-1);
   max=std::max(max,calculate(a));
   a.erase(a.begin()+i);
  }
 }
 std::cout<<max<<std::endl;

}


#include<iostream>
#include<vector>
#include<stdlib.h>
#include<time.h>
#include<math.h>
#include<string.h>
#include<algorithm>

int main(void){
 int n,m;
 int w;
 int max=-1;
 int size=0;
 int LitTime=0;
 int OffTime=0;
 std::vector <int> LitTimeTill; //a_iの時間までに点灯している時間  Cumulative sum
 std::vector <int> OffTimeTill; //a_iの時間までに消灯している時間  Cumulative sum
 std::vector<int>a;

 std::cin>>n>>m;
 a.push_back(0);
 for(int i=0; i<n; i++){
  std::cin>>w;
  a.push_back(w);
 }
 a.push_back(m);
 //LitTimeとOffTimeの累積和みたいなものを求める処理
 LitTimeTill.push_back(0);
 OffTimeTill.push_back(0);
 for(int i=1; i<a.size(); i++){
  if(i%2==1){
   LitTime+=a[i]-a[i-1];
  }
  else{
   OffTime+=a[i]-a[i-1];
  }
  LitTimeTill.push_back(LitTime);
  OffTimeTill.push_back(OffTime);
 }
 //何も追加しない場合の最終的のLitTime
 max=std::max(max,LitTime);
 size=a.size();
 //a_iの右となりにa_i+1の値を挿入した場合の最終的のLitTimeを求める処理
 for(int i=0; i<size-1; i++){
  if(a[i]+1!=a[i+1] &&i%2==0){
   max=std::max(max,LitTimeTill[i]+1+(OffTimeTill[size-1]-OffTimeTill[i+1]));
  }
  else if(a[i]+1!=a[i+1] && i%2==1){
   max=std::max(max,LitTimeTill[i]+(a[i+1]-a[i]-1)+(OffTimeTill[size-1]-OffTimeTill[i+1]));
  }
  else ;
 }
 //a_iの左となりにa_i-1の値を挿入した場合の最終的のLitTimeを求める処理
 for(int i=1; i<size; i++){
  if(a[i]-1!=a[i-1] && i%2==0){
   max=std::max(max,LitTimeTill[i-1]+1+(OffTimeTill[size-1]-OffTimeTill[i]));
  }
  else if(a[i]-1!=a[i-1] && i%2==1){
   max=std::max(max,LitTimeTill[i]-1+(OffTimeTill[size-1]-OffTimeTill[i]));
  }
  else ;
 }
 std::cout<<max<<std::endl;

}


#include<iostream>
#include<vector>
#include<stdlib.h>
#include<time.h>
#include<math.h>
#include<string.h>
#include<algorithm>

int calculate(std::vector<int>a){
 int sum=0;
 for(int i=1; i<a.size(); i+=2){
    sum+=(a[i]-a[i-1]);
 }
 return sum;
}

int main(void){
 int a,n,m;
 int w;
 int max=-1;
 int sum=0;
 int size=0;
 std::vector<int> a;

 std::cin>>n>>m;
 a.push_back(0);

 for(int i=0; i<n; i++){
  std::cin>>w;
  a.push_back(w);
 }
 a.push_back(m);

 size=a.size();
 max=std::max(max,calculate(a));
 for(int i=0; i<size-1; i++){
   if(a[i]+1!=a[i+1]){
    a.insert(a.begin()+(i+1),a[i]+1);
    max=std::max(max,calculate(a));
    a.erase(a.begin()+i+1);
   }
 }
 for(int i=1; i<size; i++){
  if(a[i]-1!=a[i-1]){
   a.insert(a.begin()+i,a[i]-1);
   max=std::max(max,calculate(a));
   a.erase(a.begin()+i);
  }
 }
 std::cout<<max<<std::endl;

}


#include<bits/stdc++.h>
using namespace std;
int a[100100];
int qz[100100];
int hz[100100];
int main(){
	int n,m;
	scanf("%d%d",&n,&m);
	a[0]=0;
	a[n+1]=m;
	for(int i=1;i<=n;i++)scanf("%d",&a[i]);
	int tmp=0;
	for(int i=0;i<=n;i+=2){
		qz[i]=tmp;
		tmp+=a[i+1]-a[i];
		qz[i+1]=tmp;
	}
	if(n%2)qz[n+1]=tmp;
	tmp=0;
	if(n%2)hz[n+1]=0;
	for(int i=(n/2)*2;i>=0;i-=2){
		hz[i+1]=tmp;
		tmp+=a[i+1]-a[i];
		hz[i]=tmp;
	}
	int ans=qz[n+1];
	//ou
	for(int i=2;i<=n+1;i+=2){
		if(a[i-1]+1>=a[i])continue;
		int ttmp=0;
		ttmp=qz[i-1];
		ttmp+=a[i]-a[i-1]-1;
		ttmp+=m-a[i]-hz[i];
		ans=max(ans,ttmp);
	}
	//ji
	for(int i=1;i<=n+1;i+=2){
		if(a[i-1]+1>=a[i])continue;
		int ttmp=0;
		ttmp=qz[i]-1;
		ttmp+=m-a[i]-hz[i];
		ans=max(ans,ttmp);
	}
	printf("%d",ans);
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int a[100100];
int qz[100100];
int hz[100100];
int main(){
	int n,m;
	scanf("%d%d",&n,&m);
	a[0]=0;
	a[n+1]=m;
	for(int i=1;i<=n;i++)scanf("%d",&a[i]);
	int tmp=0;
	for(int i=0;i<=n;i+=2){
		qz[i]=tmp;
		tmp+=a[i+1]-a[i];
		qz[i+1]=tmp;
	}
	if(n%2)qz[n+1]=tmp;
	tmp=0;
	if(n%2)hz[n+1]=0;
	for(int i=(n/2)*2;i>=0;i-=2){
		hz[i+1]=tmp;
		tmp+=a[i+1]-a[i];
		hz[i]=tmp;
	}
	int ans=qz[n+1];
	//ou
	for(int i=2;i<=n+1;i+=2){
		if(a[i-1]+1>=a[i])continue;
		int ttmp=0;
		ttmp=qz[i-1];
		ttmp+=a[i]-a[i-1]-1;
		ttmp+=m-a[i]-hz[i];
		cout<<i<<'='<<ttmp<<endl;
		ans=max(ans,ttmp);
	}
	//ji
	for(int i=1;i<=n+1;i+=2){
		if(a[i-1]+1>=a[i])continue;
		int ttmp=0;
		ttmp=qz[i]-1;
		ttmp+=m-a[i]-hz[i];
		ans=max(ans,ttmp);
	}
	printf("%d",ans);
	return 0;
}


#include <bits/stdc++.h>
using namespace std;

int main(){
  int n,m;
  scanf("%d %d",&n,&m);
  int a[n];
  for(int i=0;i<n;i++)
     scanf("%d",&a[i]);
  int left[n],right[n],rightlit[n],rightoff[n];
  for(int i=0;i<n;i++){
        if(i==0){
           left[i]=a[i];
      }
        else if(i%2==0&&i!=0){
           left[i]=left[i-1]+a[i]-a[i-1];
        }
        else  left[i]=left[i-1];
  }

  for(int i=n-1;i>=0;i--){
      if(i==n-1){
      	rightlit[i]=m-a[i];
      	rightoff[i]=0;
      	right[i]=rightlit[i];
      }
      else {
      	rightlit[i]=rightoff[i+1]+a[i+1]-a[i];
      	rightoff[i]=rightlit[i+1];
      	if(rightlit[i]>rightoff[i])
      	   right[i]=rightlit[i];
      	else right[i]=rightoff[i];
      }
  }
  int max=0;
  for(int i=0;i<n-1;i++){
      if((left[i]+rightlit[i+1])>max&&i%2==0)
         max=left[i]+rightlit[i+1];
      if((left[i]+rightoff[i+1]+a[i+1]-a[i]-1)>max&&i%2==0)
         max=left[i]+rightoff[i+1]+a[i+1]-a[i]-1;
      if(i%2==1){
         if((left[i]+rightlit[i+1]+a[i+1]-a[i]-1)>max)
         max=left[i]+rightlit[i-1]+a[i+1]-a[i]-1;
         if((left[i]+rightoff[i+1]+a[i+1]-a[i])>max)
         max=left[i]+rightoff[i+1]+a[i+1]-a[i];
      }

  }
  if(rightoff[0]+a[0]>max)
    max=rightoff[0]+a[0];
  if((a[0]-1+rightlit[0])>max)
    max=a[0]-1+rightlit[0];

  if(n%2==0){
  	if(left[n-1]+m-a[n-1]>max)
  	max=left[n-1]+m-a[n-1];
  }
  else{
  	if((left[n-1]+m-a[n-1]-1)>max)
  	max=left[n-1]+m-a[n-1]-1;
  }

  printf("%d",max);

  return 0;
}


#include <bits/stdc++.h>
using namespace std;

int main(){
  int n,m;
  scanf("%d %d",&n,&m);
  int a[n];
  for(int i=0;i<n;i++)
     scanf("%d",&a[i]);
  int left[n],right[n],rightlit[n],rightoff[n];
  for(int i=0;i<n;i++){
        if(i==0){
           left[i]=a[i];
      }
        else if(i%2==0&&i!=0){
           left[i]=left[i-1]+a[i]-a[i-1];
        }
        else  left[i]=left[i-1];
  }

  for(int i=n-1;i>=0;i--){
      if(i==n-1){
      	rightlit[i]=m-a[i];
      	rightoff[i]=0;
      	right[i]=rightlit[i];
      }
      else {
      	rightlit[i]=rightoff[i+1]+a[i+1]-a[i];
      	rightoff[i]=rightlit[i+1];
      	if(rightlit[i]>rightoff[i])
      	   right[i]=rightlit[i];
      	else right[i]=rightoff[i];
      }
  }
  int max=0;
  for(int i=0;i<n-1;i++){
      if((left[i]+rightlit[i+1])>max&&i%2==0){
         max=left[i]+rightlit[i+1];
      }
      if((left[i]+rightoff[i+1]+a[i+1]-a[i]-1)>max&&i%2==0){
         max=left[i]+rightoff[i+1]+a[i+1]-a[i]-1;
      }
      if(i%2==1){
         if((left[i]+rightlit[i+1]+a[i+1]-a[i]-1)>max){
         max=left[i]+rightlit[i+1]+a[i+1]-a[i]-1;
         }
         if((left[i]+rightoff[i+1]+a[i+1]-a[i])>max){

         max=left[i]+rightoff[i+1]+a[i+1]-a[i];
         }
      }
  }
  if(rightoff[0]+a[0]>max)
    max=rightoff[0]+a[0];
  if((a[0]-1+rightlit[0])>max)
    max=a[0]-1+rightlit[0];

  if(n%2==0){
  	if(left[n-1]+m-a[n-1]>max)
  	max=left[n-1]+m-a[n-1];
  }
  else{
  	if((left[n-1]+m-a[n-1]-1)>max)
  	max=left[n-1]+m-a[n-1]-1;
  }

  printf("%d",max);

  return 0;
}


#include <bits/stdc++.h>
using namespace std;

int main(){
  int n,m;
  scanf("%d %d",&n,&m);
  int a[n];
  for(int i=0;i<n;i++)
     scanf("%d",&a[i]);
  int left[n],rightlit[n],rightoff[n];
  for(int i=0;i<n;i++){
        if(i==0){
           left[i]=a[i];
      }
        else if(i%2==0&&i!=0){
           left[i]=left[i-1]+a[i]-a[i-1];
        }
        else  left[i]=left[i-1];
  }

  for(int i=n-1;i>=0;i--){
      if(i==n-1){
      	rightlit[i]=m-a[i];
      	rightoff[i]=0;
      }
      else {
      	rightlit[i]=rightoff[i+1]+a[i+1]-a[i];
      	rightoff[i]=rightlit[i+1];
      }
  }
  int max=0;
  for(int i=0;i<n-1;i++){
      if((left[i]+rightlit[i+1])>max&&i%2==0){
         max=left[i]+rightlit[i+1];
      }
      if((left[i]+rightoff[i+1]+a[i+1]-a[i]-1)>max&&i%2==0){
         max=left[i]+rightoff[i+1]+a[i+1]-a[i]-1;
      }
      if(i%2==1){
         if((left[i]+rightlit[i+1]+a[i+1]-a[i]-1)>max){
         max=left[i]+rightlit[i+1]+a[i+1]-a[i]-1;
         }
         if((left[i]+rightoff[i+1]+a[i+1]-a[i])>max){

         max=left[i]+rightoff[i+1]+a[i+1]-a[i];
         }
      }
  }
  if(rightoff[0]+a[0]>max)
    max=rightoff[0]+a[0];
  if((a[0]-1+rightlit[0])>max)
    max=a[0]-1+rightlit[0];

  if(n%2==0){
  	if(left[n-1]+m-a[n-1]>max)
  	max=left[n-1]+m-a[n-1];
  }
  else{
  	if((left[n-1]+m-a[n-1]-1)>max)
  	max=left[n-1]+m-a[n-1]-1;
  }

  printf("%d",max);

  return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define f(i,n) for(i=0;i<n;i++)
#define fo(i,a,n) for(i=a;i<n;i++)
int main() {
	long n,m,i=0,last=0,flag=0,tmax=0,min=m+1,val=0,smax=0;
	cin >>n >>m ;
	int ar[n],dec[m],stat[m] ;
	dec[0]=1;
	fill_n(dec,m,0) ;
	f(i,n) cin>>ar[i] ;
	f(i,n) {
	   if(i%2==0) dec[ar[i]]=-1 ;
	   else dec[ar[i]]=1 ;
	}
	dec[0]= 1 ;
	fo(i,1,m){
	    if(dec[i]==0) dec[i]=dec[i-1] ;
	}
f(i,m){
    if(dec[i]==1) smax+=1 ;
}
f(i,m){
    flag+=dec[m-1-i] ;
    stat[m-1-i]=flag ;
}
f(i,n){
    stat[ar[i]]=m+1 ;
}
f(i,m){
    if(stat[i]<min) {min=stat[i] ;val=i ;}
}
fo(i,val,m){
    dec[i]=-dec[i] ;
}
f(i,m){
    if(dec[i]==1) tmax+=1 ;
}
if(smax<tmax)cout<<tmax ;
else cout <<smax ;
return 0 ;
}


#include <bits/stdc++.h>
using namespace std;
#define f(i,n) for(i=0;i<n;i++)
#define fo(i,a,n) for(i=a;i<n;i++)
int main() {
	int n,m,i=0,last=0,flag=0,tmax=0,min=m+1,val=0,smax=0;
	cin >>n >>m ;
	int ar[n],dec[m],stat[m] ;
	dec[0]=1;
	fill_n(dec,m,0) ;
	f(i,n) cin>>ar[i] ;
	f(i,n) {
	   if(i%2==0) dec[ar[i]]=-1 ;
	   else dec[ar[i]]=1 ;
	}
	dec[0]= 1 ;
	fo(i,1,m){
	    if(dec[i]==0) dec[i]=dec[i-1] ;
	}
f(i,m){
    if(dec[i]==1) smax+=1 ;
}
f(i,m){
    flag+=dec[m-1-i] ;
    stat[m-1-i]=flag ;
}
f(i,n){
    stat[ar[i]]=m+1 ;
}
f(i,m){
    if(stat[i]<min) {min=stat[i] ;val=i ;}
}
fo(i,val,m){
    dec[i]=-dec[i] ;
}
f(i,m){
    if(dec[i]==1) tmax+=1 ;
}
if(smax<tmax)cout<<tmax ;
else cout <<smax ;
return 0 ;
}


#include <bits/stdc++.h>
using namespace std;
#define f(i,n) for(i=0;i<n;i++)
#define fo(i,a,n) for(i=a;i<n;i++)
int main() {
	int n,m,i=0,last=0,flag=0,tmax=0,min=m+1,val=0;
	cin >>n >>m ;
	int ar[n],dec[m],stat[m] ;
	dec[0]=1;
	fill_n(dec,m,0) ;
	f(i,n) cin>>ar[i] ;
	f(i,n) {
	   if(i%2==0) dec[ar[i]]=-1 ;
	   else dec[ar[i]]=1 ;
	}
	dec[0]= 1 ;
	fo(i,1,m){
	    if(dec[i]==0) dec[i]=dec[i-1] ;
	}

f(i,m){
    flag+=dec[m-1-i] ;
    stat[m-1-i]=flag ;
}
f(i,n){
    stat[ar[i]]=m+1 ;
}
f(i,m){
    if(stat[i]<min) {min=stat[i] ;val=i ;}
}
fo(i,val,m){
    dec[i]=-dec[i] ;
}
f(i,m){
    if(dec[i]==1) tmax+=1 ;
}
cout<<tmax ;
return 0 ;
}


#include<iostream>
#include<vector>
using namespace std;
struct self{
    int left;
    int right;
    int len;
    long long afterlen=0;
};
int main()
{
    int n,m;
    cin>>n>>m;
    vector<self> v;
    int *p=new int[n+2];
    p[0]=0;
    for(int i=1;i<=n;i++)
        cin>>p[i];
    p[n+1]=m;
    long long cur_total=0;
    long long after=0;
    //int *on=new int[n+2];
    for(int i=0;i<=n;i+=2)
    {
        self t;
        t.left=p[i];
        t.right=p[i+1];
        t.len=p[i+1]-p[i];
        after+=t.len;
        t.afterlen=after;
        v.push_back(t);
        cur_total+=t.len;
    }
    for(int i=0;i<v.size();i++)
        v[i].afterlen=cur_total-v[i].afterlen;
    //for(int i=0;i<v.size();i++)
        //cout<<v[i].left<<" "<<v[i].right<<" "<<v[i].len<<" "<<v[i].afterlen<<endl;
    long long _max=cur_total;
    for(int i=0;i<v.size();i++)
    {
        int r=v[i].right;
        long long len=v[i].afterlen;
        long long temp=m-r-len-1+cur_total-len;
        if(_max<temp)
            _max=temp;
    }
    cout<<_max<<endl;
}


#include<iostream>
#include<vector>
using namespace std;
struct self{
    int left;
    int right;
    int len;
    long long afterlen;
};
int main()
{
    int n,m;
    cin>>n>>m;
    vector<self> v;
    int *p=new int[n+2];
    p[0]=0;
    for(int i=1;i<=n;i++)
        cin>>p[i];
    p[n+1]=m;
    long long cur_total=0;
    long long after=0;
    //int *on=new int[n+2];
    for(int i=0;i<=n;i+=2)
    {
        self t;
        t.left=p[i];
        t.right=p[i+1];
        t.len=p[i+1]-p[i];
        after+=t.len;
        t.afterlen=after;
        v.push_back(t);
        cur_total+=t.len;
    }
    for(int i=0;i<v.size();i++)
        v[i].afterlen=cur_total-v[i].afterlen;
    //for(int i=0;i<v.size();i++)
        //cout<<v[i].left<<" "<<v[i].right<<" "<<v[i].len<<" "<<v[i].afterlen<<endl;
    long long _max=cur_total;
    for(int i=0;i<v.size();i++)
    {
        int r=v[i].right;
        long long len=v[i].afterlen;
        long long temp=m-r-len-1+cur_total-len;
        if(_max<temp)
            _max=temp;
    }
    cout<<_max<<endl;
}


#include<bits/stdc++.h>
using namespace std;
#define maxn 100020
#define rep(i,l,r) for(register int i = l ; i <= r ; i++)
#define repd(i,r,l) for(register int i = r ; i >= l ; i--)
#define inf 1e8

typedef long long ll;
inline int read(){
	register int num = 0;
	register char ch = getchar();
	while ( ch > '9' || ch < '0' ) ch = getchar();
	while ( ch <= '9' && ch >= '0' ) num = num * 10 + ch - '0' , ch = getchar();
	return num;
}
int num[10];
inline void write(int x){
	register int cnt = 0;
	if ( !x ){ printf("0"); return; } //一定要特判0！！！
	while ( x ) num[++cnt] = x % 10 , x /= 10;
	while ( cnt ) putchar(num[cnt--] + '0');
}
int n,m;

int a[maxn],ans,sum[maxn],tag[maxn];

int main(){
	scanf("%d %d",&n,&m);
	int t = 1;
	rep(i,1,n){
	   	scanf("%d",&a[i]);
		if ( t ) ans += a[i] - a[i - 1];
		t ^= 1;
		tag[i] = t;
	}
	a[n + 1] = m;
	if ( t ) ans += m - a[n];
	int cur = ans;
	repd(i,n,1){
		sum[i] = sum[i + 1] + tag[i] * (a[i + 1] - a[i]);
		cur = max(cur,ans + m - a[i] - sum[i] - 1 - sum[i]);
	}
//	rep(i,1,n) cout<<sum[i]<<" ";
//	cout<<endl;
	printf("%d\n",cur);
}


/*
ID: m.estek1
PROG: test
LANG: C++
*/

//In the name of Allah

#include <bits/stdc++.h>
using namespace std;
ofstream fout("test.out");
ifstream fin("test.in");
#define int long long
#define ll long long
#define ld long double
#define pb push_back
#define pf push_front
#define F first
#define S second
#define TL ios::sync_with_stdio(0); cin.tie(0);cout.tie(0);
const int MX=2e5+100 ,INF=1e18,INF2=-1e18,D=1e9+7;
int  n,m,arr[MX],big,x,sum,sum1;
int32_t main(){
    TL
    cin>>n>>m;
    arr[0]=0;
    for(int i=0 ; i<n ; i++){
        cin>>arr[i+1];

    }
    arr[n+1]=m;
    for(int i=1 ; i<n+2 ; i++){
        if(i%2==1){
            sum1+=arr[i]-arr[i-1];
        }
    }
    for(int i=n; i >=1 ; i--){
        if(n%2==1){
            if(i%2==1){
                sum-=arr[i+1]-arr[i];
            }
            else{
                sum+=arr[i+1]-arr[i];
            }
        }
        else{
            if(i%2==0){
                sum+=arr[i+1]-arr[i];
            }
            else{
                sum-=arr[i+1]-arr[i];
            }
        }
        //cout<<sum<<" "<<arr[i]<<" "<<arr[i-1]<<endl;
        if(sum<big && (arr[i-1]!=arr[i]-1 || arr[i]+1!=arr[i+1])){
            big=sum;
            x=i;
        }
    }
    //cout<<big<< " " <<sum1<<endl;
    if(big<0)
        sum1+=abs(big)-1;
    cout<<sum1<<endl;
    return 0;
}


/*
ID: m.estek1
PROG: test
LANG: C++
*/

//In the name of Allah

#include <bits/stdc++.h>
using namespace std;
ofstream fout("test.out");
ifstream fin("test.in");
#define int long long
#define ll long long
#define ld long double
#define pb push_back
#define pf push_front
#define F first
#define S second
#define TL ios::sync_with_stdio(0); cin.tie(0);cout.tie(0);
const int MX=2e5+100 ,INF=1e18,INF2=-1e18,D=1e9+7;
int  n,m,arr[MX],big,x,sum,sum1;
int32_t main(){
    TL
    cin>>n>>m;
    arr[0]=0;
    for(int i=0 ; i<n ; i++){
        cin>>arr[i+1];

    }
    arr[n+1]=m;
    for(int i=1 ; i<n+2 ; i++){
        if(i%2==1){
            sum1+=arr[i]-arr[i-1];
        }
    }
    for(int i=n; i >=1 ; i--){
        if(n%2==1){
            if(i%2==1){
                sum-=arr[i+1]-arr[i];
            }
            else{
                sum+=arr[i+1]-arr[i];
            }
        }
        else{
            if(i%2==0){
                sum+=arr[i+1]-arr[i];
            }
            else{
                sum-=arr[i+1]-arr[i];
            }
        }
        //cout<<sum<<" "<<arr[i]<<" "<<arr[i-1]<<endl;
        if(sum<big && (arr[i-1]!=arr[i]-1 || arr[i]+1!=arr[i+1])){
            big=sum;
            x=i;
        }
    }
    //cout<<big<< " " <<sum1<<endl;
    if(big>0)
        sum1+=abs(big)-1;
    cout<<sum1<<endl;
    return 0;
}


#include<algorithm>
#include<clocale>
#include<cmath>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<deque>
#include<iostream>
#include<istream>
#include<map>
#include<math.h>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<string>
#include<vector>
using namespace std;
int n,m,a[200010],ans,sum[200010];
int main(){
	cin>>n>>m;
	for (int i=1;i<=n;i++) cin>>a[i];
	for (int i=1;i<=n;i++){
		if (i%2==0) sum[i]=sum[i-1]-a[i];
		if (i%2==1) sum[i]=sum[i-1]+a[i];
	}
	for (int i=1;i<=n;i++){
		int x=sum[i]*2-sum[n];
		if (n%2==1) x+=m;
		if (i%2==0)
			x+=a[i+1]-1;
		else
			x-=a[i]+1;
		ans=max(ans,x);
	}
	ans=max(ans,-sum[n]+a[1]-1+((n%2)?m:0));
	ans=max(ans,sum[n]+((n%2)?0:m));
	cout<<ans<<endl;
	return 0;
}


#include<algorithm>
#include<clocale>
#include<cmath>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<deque>
#include<iostream>
#include<istream>
#include<map>
#include<math.h>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<string>
#include<vector>
using namespace std;
int n,m,a[200010],ans=0,b[200010];
int main(){
	cin>>n>>m;
	for (int i=0;i<n;i++) cin>>a[i];
	int lbound=0,ubound=m;
	if (n%2==1)
		while (lbound<ubound){
			for (int i=0;i<n*2;i++) b[i]=0;
			b[n+2]=m;
			int mid=(ubound+lbound)/2,i=0,last=0,num=0;
			for (;i<n;i++) if (mid>a[i]) break;
			for (int j=0;j<=i;j++) b[j+1]=a[j];
			b[i+2]=mid;
			for (int j=i+1;j<n;j++) b[j+2]=a[j];
			for (i=0;i<=n+2;i++)
				if (i%2==0)
					last=b[i];
				else
					num+=b[i]-last;
			if (num>ans){
				lbound=mid+1;
				ans=num;
			}
			else
				ubound=mid-1;
		}
	else
		while (lbound<ubound){
			for (int i=0;i<n*2;i++) b[i]=0;
			b[n+2]=m;
			int mid=(ubound+lbound)/2,i=0,last=0,num=0;
			for (;i<n;i++) if (mid>a[i]) break;
			for (int j=0;j<=i;j++) b[j+1]=a[j];
			b[i+2]=mid;
			for (int j=i+1;j<n;j++) b[j+2]=a[j];
			for (i=0;i<=n+2;i++)
				if (i%2==0)
					last=b[i];
				else
					num+=b[i]-last;
			if (num>ans){
				ubound=mid-1;
				ans=num;
			}
			else
				lbound=mid+1;
		}
	int num=0,last=0;
	a[n]=m;
	for (int i=0;i<=n;i++)
		if (i%2==1)
			last=a[i];
		else
			num+=a[i]-last;
	cout<<max(num,ans)<<endl;
	return 0;
}


#include<algorithm>
#include<clocale>
#include<cmath>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<deque>
#include<iostream>
#include<istream>
#include<map>
#include<math.h>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<string>
#include<vector>
using namespace std;
int n,m,a[200010],ans=0,b[200010];
int main(){
	cin>>n>>m;
	for (int i=0;i<n;i++) cin>>a[i];
	int lbound=0,ubound=m;
	if (n%2==1)
		while (lbound<ubound){
			for (int i=0;i<n*2;i++) b[i]=0;
			b[n+2]=m;
			int mid=(ubound+lbound)/2,i=0,last=0,num=0;
			for (;i<n;i++) if (mid>a[i]) break;
			for (int j=0;j<=i;j++) b[j+1]=a[j];
			b[i+2]=mid;
			for (int j=i+1;j<n;j++) b[j+2]=a[j];
			for (i=0;i<=n+2;i++)
				if (i%2==0)
					last=b[i];
				else
					num+=b[i]-last;
			for (int i=0;i<n+3;i++) cout<<b[i]<<' ';
			cout<<endl;
			if (num>ans){
				lbound=mid+1;
				ans=num;
			}
			else
				ubound=mid-1;
		}
	else
		while (lbound<ubound){
			for (int i=0;i<n*2;i++) b[i]=0;
			b[n+2]=m;
			int mid=(ubound+lbound)/2,i=0,last=0,num=0;
			for (;i<n;i++) if (mid>a[i]) break;
			for (int j=0;j<=i;j++) b[j+1]=a[j];
			b[i+2]=mid;
			for (int j=i+1;j<n;j++) b[j+2]=a[j];
			for (i=0;i<=n+2;i++)
				if (i%2==0)
					last=b[i];
				else
					num+=b[i]-last;
			if (num>ans){
				ubound=mid-1;
				ans=num;
			}
			else
				lbound=mid+1;
		}
	int num=0,last=0;
	a[n]=m;
	for (int i=0;i<=n;i++)
		if (i%2==1)
			last=a[i];
		else
			num+=a[i]-last;
	cout<<max(num,ans)<<endl;
	return 0;
}


#include<algorithm>
#include<clocale>
#include<cmath>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<deque>
#include<iostream>
#include<istream>
#include<map>
#include<math.h>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<string>
#include<vector>
using namespace std;
int n,m,a[200010],ans=0;
int main(){
	cin>>n>>m;
	for (int i=1;i<=n;i++) cin>>a[i];
	a[n+1]=m;n+=2;
	for (int i=1;i<n;i++){
		int num=0,last=0;
		if (i%2==1){
			for (int j=0;j<i;j++)
				if (j%2==0)
					last=a[j];
				else
					num+=a[j]-last;
			last=0;
			for (int j=i;j<n;j++)
				if (j%2==1)
					last=a[j];
				else
					num+=a[j]-last;
		}
		else{
			for (int j=0;j<i;j++)
				if (j%2==0)
					last=a[j];
				else
					num+=a[j]-last;
			last=0;
			for (int j=i+1;j<n;j++)
				if (j%2==1)
					last=a[j];
				else
					num+=a[j]-last;
		}
		ans=max(ans,num+a[i]-a[i-1]-1);
	}
	cout<<ans<<endl;
	return 0;
}


#include<algorithm>
#include<clocale>
#include<cmath>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<deque>
#include<iostream>
#include<istream>
#include<map>
#include<math.h>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<string>
#include<vector>
using namespace std;
int n,m,a[200010],ans=0,b[200010];
int main(){
	cin>>n>>m;
	for (int i=0;i<n;i++) cin>>a[i];
	int lbound=0,ubound=m;
	a[n]=m;
	while (lbound<ubound){
		for (int i=0;i<n*2;i++) b[i]=0;
		int mid=(ubound+lbound)/2,i=0,last=0,num=0;
		for (;i<n;i++) if (mid<a[i]) break;
		for (int j=0;j<i;j++) b[j+1]=a[j];
		b[i+1]=mid;
		for (int j=i;j<=n;j++) b[j+2]=a[j];
		for (i=0;i<=n+2;i++)
			if (i%2==0)
				last=b[i];
			else
				num+=b[i]-last;
		if (num>ans){
			lbound=mid+1;
			ans=num;
		}
		else
			ubound=mid-1;
	}
	int sum=ans;
	ans=lbound=0;ubound=m;
	while (lbound<ubound){
		for (int i=0;i<n*2;i++) b[i]=0;
		int mid=(ubound+lbound)/2,i=0,last=0,num=0;
		for (;i<n;i++) if (mid<a[i]) break;
		for (int j=0;j<i;j++) b[j+1]=a[j];
		b[i+1]=mid;
		for (int j=i;j<=n;j++) b[j+2]=a[j];
			for (i=0;i<=n+2;i++)
		if (i%2==0)
				last=b[i];
			else
				num+=b[i]-last;
		if (num>=ans){
			ubound=mid-1;
			ans=num;
		}
		else
			lbound=mid+1;
	}
	int num=0,last=0;
	for (int i=0;i<=n;i++)
		if (i%2==1)
			last=a[i];
		else
			num+=a[i]-last;
	cout<<max(max(num,sum),ans)<<endl;
	return 0;
}


#include<algorithm>
#include<clocale>
#include<cmath>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<deque>
#include<iostream>
#include<istream>
#include<map>
#include<math.h>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<string>
#include<vector>
using namespace std;
int n,m,a[200010],ans=0;
int main(){
	cin>>n>>m;
	for (int i=1;i<=n;i++) cin>>a[i];
	a[n+1]=m;n+=2;
	for (int i=1;i<n;i++){
		int num=0,last=0;
		if (i%2==1){
			for (int j=0;j<i;j++)
				if (j%2==0)
					last=a[j];
				else
					num+=a[j]-last;
			last=0;
			for (int j=i;j<n;j++)
				if (j%2==1)
					last=a[j];
				else
					num+=a[j]-last;
		}
		else{
			for (int j=0;j<i;j++)
				if (j%2==0)
					last=a[j];
				else
					num+=a[j]-last;
			last=0;
			for (int j=i+1;j<n;j++)
				if (j%2==1)
					last=a[j];
				else
					num+=a[j]-last;
		}
		ans=max(ans,num+a[i]-a[i-1]-1);
	}
	int num=0,last=0;
	for (int i=0;i<=n;i++)
		if (i%2==0)
			last=a[i];
		else
			num+=a[i]-last;
	cout<<max(num,ans)<<endl;
	return 0;
}


#include<algorithm>
#include<clocale>
#include<cmath>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<deque>
#include<iostream>
#include<istream>
#include<map>
#include<math.h>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<string>
#include<vector>
using namespace std;
int n,m,a[200010],ans=0,b[200010];
int main(){
	cin>>n>>m;
	for (int i=0;i<n;i++) cin>>a[i];
	int lbound=0,ubound=m;
	a[n]=m;
	if (n%2==1)
		while (lbound<ubound){
			for (int i=0;i<n*2;i++) b[i]=0;
			int mid=(ubound+lbound)/2,i=0,last=0,num=0;
			for (;i<n;i++) if (mid<a[i]) break;
			for (int j=0;j<i;j++) b[j+1]=a[j];
			b[i+1]=mid;
			for (int j=i;j<=n;j++) b[j+2]=a[j];
			for (i=0;i<=n+2;i++)
				if (i%2==0)
					last=b[i];
				else
					num+=b[i]-last;
			if (num>ans){
				lbound=mid+1;
				ans=num;
			}
			else
				ubound=mid-1;
		}
	else
		while (lbound<ubound){
			for (int i=0;i<n*2;i++) b[i]=0;
			int mid=(ubound+lbound)/2,i=0,last=0,num=0;
			for (;i<n;i++) if (mid<a[i]) break;
			for (int j=0;j<i;j++) b[j+1]=a[j];
			b[i+1]=mid;
			for (int j=i;j<=n;j++) b[j+2]=a[j];
			for (i=0;i<=n+2;i++)
				if (i%2==0)
					last=b[i];
				else
					num+=b[i]-last;
			if (num>ans){
				ubound=mid-1;
				ans=num;
			}
			else
				lbound=mid+1;
		}
	int num=0,last=0;
	for (int i=0;i<=n;i++)
		if (i%2==1)
			last=a[i];
		else
			num+=a[i]-last;
	cout<<max(num,ans)<<endl;
	return 0;
}


#include<iostream>
#include<cstdlib>
#include<cstdio>
#include<cstring>
#include<queue>
#include<vector>
#include<algorithm>
#include<cmath>
typedef long long ll;
using namespace std;
const int INF=0x3f3f3f3f;
const int model=1000000007;
int arr[100005],tim[100005];
int main()
{
	int n,m,i,j,k,temp,sum1=0,sum2=0,mx=0,sum=0;
	scanf("%d%d",&n,&m);
	arr[0]=0;
	for(i=1;i<=n;i++){
		scanf("%d",&arr[i]);
		tim[i-1]=arr[i]-arr[i-1];
	}
	tim[n]=m-arr[n];
	for(i=0;i<=n;i++)
		if(i%2==0)
			sum1+=tim[i];
		else
			sum2+=tim[i];
	mx=sum1;
	sum=tim[0];
	for(i=2;i<=n;i+=2){
		mx=max(mx,sum+sum2-1);
		sum2-=tim[i-1];
		sum+=tim[i];
	}
	mx=max(mx,sum+sum2-1);
	printf("%d\n",mx);
}


#include<iostream>
#include<cstdlib>
#include<cstdio>
#include<cstring>
#include<queue>
#include<vector>
#include<algorithm>
#include<cmath>
typedef long long ll;
using namespace std;
const int INF=0x3f3f3f3f;
const int model=1000000007;
int arr[100005],tim[100005];
int main()
{
	int n,m,i,j,k,temp,sum1=0,sum2=0,mx=0,sum=0;
	scanf("%d%d",&n,&m);
	arr[0]=0;
	for(i=1;i<=n;i++){
		scanf("%d",&arr[i]);
		tim[i-1]=arr[i]-arr[i-1];
	}
	tim[n]=m-arr[n];
	for(i=0;i<=n;i++)
		if(i%2==0)
			sum1+=tim[i];
		else
			sum2+=tim[i];
	mx=sum1;
	sum=tim[0];
	for(i=2;i<=n;i+=2){
		mx=max(mx,sum+sum2-1);
		sum2-=tim[i-1];
		sum+=tim[i];
	}
	printf("%d\n",mx);
}


#include<iostream>
#include<cstdlib>
#include<cstdio>
#include<cstring>
#include<queue>
#include<vector>
#include<algorithm>
#include<cmath>
typedef long long ll;
using namespace std;
const int INF=0x3f3f3f3f;
const int model=1000000007;
int arr[100005],tim[100005];
int main()
{
	int n,m,i,j,k,temp,sum1=0,sum2=0,mx,sum=0;
	scanf("%d%d",&n,&m);
	arr[0]=0;
	for(i=1;i<=n;i++){
		scanf("%d",&arr[i]);
		tim[i-1]=arr[i]-arr[i-1];
	}
	tim[n]=m-arr[n];
	for(i=0;i<=n;i++)
		if(i%2==0)
			sum1+=tim[i];
		else
			sum2+=tim[i];
	mx=sum1;
	sum=tim[0];
	for(i=2;i<=n;i+=2){
		mx=max(mx,sum+sum2-1);
		sum2-=tim[i-1];
		sum+=tim[i];
	}
	printf("%d\n",mx);
}


#include<iostream>
#include<cstdlib>
#include<cstdio>
#include<cstring>
#include<queue>
#include<vector>
#include<algorithm>
#include<cmath>
typedef long long ll;
using namespace std;
const int INF=0x3f3f3f3f;
const int model=1000000007;
int arr[100005],tim[100005];
int main()
{
	int n,m,i,j,k,temp,sum1=0,sum2=0,mx,sum=0;
	scanf("%d%d",&n,&m);
	arr[0]=0;
	for(i=1;i<=n;i++){
		scanf("%d",&arr[i]);
		tim[i-1]=arr[i]-arr[i-1];
	}
	tim[n]=m-arr[n];
	for(i=0;i<=n;i++)
		if(i%2==0)
			sum1+=tim[i];
		else
			sum2+=tim[i];
	mx=max(sum1,sum2);
	sum=tim[0];
	for(i=2;i<=n;i+=2){
		mx=max(mx,sum+sum2-1);
		sum2-=tim[i-1];
		sum+=tim[i];
	}
	printf("%d\n",mx);
}


#include<bits/stdc++.h>
using namespace std;

int main()
{
    int n,m,num[101000];
    int suml[101000],sumr[101000];
    scanf("%d %d",&n,&m);
    num[0]=0;
    num[n+1]=m;
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&num[i]);
        if(i%2==1)
        {
            suml[i]=num[i]-num[i-1]+suml[i-1];
            sumr[i]=sumr[i-1];
        }
        else
        {
            sumr[i]=num[i]-num[i-1]+sumr[i-1];
            suml[i]=suml[i-1];
        }
    }
    if((n+1)%2==1)
    {
        suml[n+1]=num[n+1]-num[n]+suml[n];
        sumr[n+1]=sumr[n];
    }
    else
    {
        sumr[n+1]=num[n+1]-num[n]+sumr[n];
        suml[n+1]=suml[n];
    }
    //for(int i=0;i<=n+1;i++)
    //{
    //    printf("%d %d\n",suml[i],sumr[i]);
    //}
    int ans=suml[n+1];
    for(int i=1;i<=n+1;i++)
    {
        int cnt=0;
        if(i%2==1&&num[i]-num[i-1]>1)
        {
            cnt=suml[i]-1+sumr[n+1]-sumr[i];
            //printf("%d\n",cnt);
            if(cnt>ans)
                ans=cnt;
        }
        else if(i%2==0&&num[i]-num[i-1]>1)
        {
            cnt=sumr[i]-1+sumr[n+1]-sumr[i]+suml[i-1];
            //printf("%d\n",cnt);
            if(cnt>ans)
                ans=cnt;
        }
    }
    printf("%d\n",ans);
    return 0;
}


#include<bits/stdc++.h>
using namespace std;

int main()
{
    int n,m,num[101000];
    int suml[101000],sumr[101000];
    scanf("%d %d",&n,&m);
    num[0]=0;
    num[n+1]=m;
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&num[i]);
        if(i%2==1)
        {
            suml[i]=num[i]-num[i-1]+suml[i-1];
            sumr[i]=sumr[i-1];
        }
        else
        {
            sumr[i]=num[i]-num[i-1]+sumr[i-1];
            suml[i]=suml[i-1];
        }
    }
    if((n+1)%2==1)
    {
        suml[n+1]=num[n+1]-num[n]+suml[n];
        sumr[n+1]=sumr[n];
    }
    else
    {
        sumr[n+1]=num[n+1]-num[n]+sumr[n];
        suml[n+1]=suml[n];
    }
    //for(int i=0;i<=n+1;i++)
    //{
    //    printf("%d %d\n",suml[i],sumr[i]);
    //}
    int ans=suml[n+1];
    for(int i=1;i<=n+1;i++)
    {
        int cnt=0;
        if(i%2==1&&num[i]-num[i-1]>1)
        {
            cnt=suml[i]-1+sumr[n+1]-sumr[i];
            //printf("%d\n",cnt);
            if(cnt>ans)
                ans=cnt;
        }
        else if(i%2==0&&num[i]-num[i-1]>1)
        {
            cnt=sumr[i]-sumr[i-1]-1+sumr[n+1]-sumr[i]+suml[i-1];
            //printf("%d\n",cnt);
            if(cnt>ans)
                ans=cnt;
        }
    }
    printf("%d\n",ans);
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

int main() {
	int n, M; scanf("%d %d", &n, &M);
	int unchanged[10010] = {0};
	int changed[10010] = {0};
	int a = 0; int b = 0;
	int index = 0;
	for (int i = 1; i <= n; i++) {
		scanf("%d", &b);
		if (index % 2 == 0) {
			unchanged[i] = b - a;
			changed[i] = 0;
		} else {
			changed[i] = b - a;
			unchanged[i] = 0;
		}
		index++;
		a = b;
	}
	if (index % 2 == 0) {
		unchanged[n + 1] = M - a;
	} else {
		changed[n + 1] = M - a;
	}

	int max = 0;
	for (int i = 1; i <= n + 1; i++) {
	    max += unchanged[i];
	}
	int unchanged_sum[10010] = {0};
	int changed_sum[10010] = {0};
	for (int i = n + 1; i >= 1; i--) {
	    for (int j = 1; j <= i; j++) {
	        unchanged_sum[i] += unchanged[j];
	    }
	}
	for (int i = 1; i <= n + 1; i++) {
	    for (int j = i; j <= n + 1; j++) {
	        changed_sum[i] += changed[j];
	    }
	}
	int temp = 0;
	for (int i = n + 1; i >= 1; i--) {
		temp = 0;
		if (unchanged[i] >= 2) {
			temp += unchanged_sum[i];
			temp += changed_sum[i + 1];
			temp--;
		} else if (changed[i] >= 2) {
			temp += unchanged_sum[i - 1];
			temp += changed_sum[i];
			temp--;
		}
		if (max < temp) {
			max = temp;
		}
	}
	printf("%d", max);
}


#include <bits/stdc++.h>
using namespace std;

int main() {
	int n, M; scanf("%d %d", &n, &M);
	int unchanged[10010] = {0};
	int changed[10010] = {0};
	int a = 0; int b = 0;
	int index = 0;
	for (int i = 1; i <= n; i++) {
		scanf("%d", &b);
		if (index % 2 == 0) {
			unchanged[i] = b - a;
			changed[i] = 0;
		} else {
			changed[i] = b - a;
			unchanged[i] = 0;
		}
		index++;
		a = b;
	}
	if (index % 2 == 0) {
		unchanged[n + 1] = M - a;
	} else {
		changed[n + 1] = M - a;
	}

	int max = 0;
	for (int i = 1; i <= n + 1; i++) {
	    max += unchanged[i];
	}
	int unchanged_sum[10010] = {0};
	int changed_sum[10010] = {0};
	for (int i = n + 1; i >= 1; i--) {
	    for (int j = 1; j <= i; j++) {
	        unchanged_sum[i] += unchanged[j];
	    }
	}
	for (int i = 1; i <= n + 1; i++) {
	    for (int j = i; j <= n + 1; j++) {
	        changed_sum[i] += changed[j];
	    }
	}
	int temp = 0;
	for (int i = n + 1; i >= 1; i--) {
		temp = 0;
		if (unchanged[i] >= 2) {
			temp += unchanged_sum[i];
			temp += changed_sum[i + 1];
			temp--;
		} else if (changed[i] >= 2) {
			temp += unchanged_sum[i];
			temp += changed_sum[i + 1];
			temp--;
		}
		if (max < temp) {
			max = temp;
		}
	}
	printf("%d", max);
}


#include <bits/stdc++.h>
using namespace std;

int main() {
	int n, M; scanf("%d %d", &n, &M);
	int unchanged[10010] = {0};
	int changed[10010] = {0};
	int a = 0; int b = 0;
	int index = 0;
	for (int i = 1; i <= n; i++) {
		scanf("%d", &b);
		if (index % 2 == 0) {
			unchanged[i] = b - a;
			changed[i] = 0;
		} else {
			changed[i] = b - a;
			unchanged[i] = 0;
		}
		index++;
		a = b;
	}
	if (index % 2 == 0) {
		unchanged[n + 1] = M - a;
	} else {
		changed[n + 1] = M - a;
	}

	int max = 0;
	for (int i = 1; i <= n + 1; i++) {
	    max += unchanged[i];
	}
	int unchanged_sum[10010] = {0};
	int changed_sum[10010] = {0};

	int memo = 0;
	for (int i = 1; i <= n + 1; i++) {
	    memo += unchanged[i];
	    unchanged_sum[i] = memo;
	}
	memo = 0;
	for (int j = n + 1; j >= 1; j--) {
	    memo += changed[j];
	    changed_sum[j] = memo;
	}

	int temp = 0;
	for (int i = n + 1; i >= 1; i--) {
		temp = 0;
		if (unchanged[i] >= 2) {
			temp += unchanged_sum[i];
			temp += changed_sum[i + 1];
			temp--;
		} else if (changed[i] >= 2) {
			temp += unchanged_sum[i - 1];
			temp += changed_sum[i];
			temp--;
		}
		if (max < temp) {
			max = temp;
		}
	}
	printf("%d", max);
}


#include <bits/stdc++.h>
using namespace std;

int main() {
	int n, M; scanf("%d %d", &n, &M);
	int unchanged[10010] = {0};
	int changed[10010] = {0};
	int a = 0; int b = 0;
	int index = 0;
	for (int i = 1; i <= n; i++) {
		scanf("%d", &b);
		if (index % 2 == 0) {
			unchanged[i] = b - a;
			changed[i] = 0;
		} else {
			changed[i] = b - a;
			unchanged[i] = 0;
		}
		index++;
		a = b;
	}
	if (index % 2 == 0) {
		unchanged[n + 1] = M - a;
	} else {
		changed[n + 1] = M - a;
	}

	int max = 0;
	for (int i = 1; i <= n + 1; i++) {
	    max += unchanged[i];
	}
	int temp = 0;
	for (int i = n + 1; i >= 1; i--) {
		temp = 0;
		if (unchanged[i] >= 2) {
			for (int j = 1; j <= i; j++) {
				temp += unchanged[j];
			}
			for (int k = i + 1; k <= n + 1; k++) {
				temp += changed[k];
			}
			temp--;
		} else if (changed[i] >= 2) {
			for (int j = 1; j <= i - 1; j++) {
				temp += unchanged[j];
			}
			for (int k = i; k <= n + 1; k++) {
				temp += changed[k];
			}
			temp--;
		}
		if (max < temp) {
			max = temp;
		}
	}
	printf("%d", max);
}


#include <bits/stdc++.h>
using namespace std;

int main() {
	long long int n, M; scanf("%lli %lli", &n, &M);
	long long int unchanged[10010] = {0};
	long long int changed[10010] = {0};
	long long int a = 0; long long int b = 0;
	long long int index = 0;
	for (int i = 1; i <= n; i++) {
		scanf("%lli", &b);
		if (index % 2 == 0) {
			unchanged[i] = b - a;
			changed[i] = 0;
		} else {
			changed[i] = b - a;
			unchanged[i] = 0;
		}
		index++;
		a = b;
	}
	if (index % 2 == 0) {
		unchanged[n + 1] = M - a;
	} else {
		changed[n + 1] = M - a;
	}

	long long int max = 0;
	long long int unchanged_sum[10010] = {0};
	long long int changed_sum[10010] = {0};

	long long int memo = 0;
	long long int memo2 = 0;
	for (int i = 1; i <= n + 1; i++) {
	    memo += unchanged[i];
	    unchanged_sum[i] = memo;
	    memo2 += changed[n + 2 - i];
	    changed_sum[n + 2 - i] = memo2;
	}
	max = unchanged_sum[n+1];
	long long int temp = 0;
	for (int i = n + 1; i >= 1; i--) {
		temp = 0;
		if (unchanged[i] >= 2) {
			temp += unchanged_sum[i];
			temp += changed_sum[i + 1];
			temp--;
		} else if (changed[i] >= 2) {
			temp += unchanged_sum[i - 1];
			temp += changed_sum[i];
			temp--;
		}
		if (max < temp) {
			max = temp;
		}
	}
	printf("%lli", max);
}


#include <bits/stdc++.h>
using namespace std;

int main() {
	long long int n, M; scanf("%lli %lli", &n, &M);
	long long int unchanged[10010] = {0};
	long long int changed[10010] = {0};
	long long int a = 0; long long int b = 0;
	long long int index = 0;
	for (int i = 1; i <= n; i++) {
		scanf("%lli", &b);
		if (index % 2 == 0) {
			unchanged[i] = b - a;
			changed[i] = 0;
		} else {
			changed[i] = b - a;
			unchanged[i] = 0;
		}
		index++;
		a = b;
	}
	if (index % 2 == 0) {
		unchanged[n + 1] = M - a;
	} else {
		changed[n + 1] = M - a;
	}

	long long int max = 0;
	for (int i = 1; i <= n + 1; i++) {
	    max += unchanged[i];
	}
	long long int unchanged_sum[10010] = {0};
	long long int changed_sum[10010] = {0};

	long long int memo = 0;
	for (int i = 1; i <= n + 1; i++) {
	    memo += unchanged[i];
	    unchanged_sum[i] = memo;
	}
	memo = 0;
	for (int j = n + 1; j >= 1; j--) {
	    memo += changed[j];
	    changed_sum[j] = memo;
	}

	long long int temp = 0;
	for (int i = n + 1; i >= 1; i--) {
		temp = 0;
		if (unchanged[i] >= 2) {
			temp += unchanged_sum[i];
			temp += changed_sum[i + 1];
			temp--;
		} else if (changed[i] >= 2) {
			temp += unchanged_sum[i - 1];
			temp += changed_sum[i];
			temp--;
		}
		if (max < temp) {
			max = temp;
		}
	}
	printf("%lli", max);
}


#include <bits/stdc++.h>
using namespace std;

int main() {
	long long int n, M; scanf("%lli %lli", &n, &M);
	long long int unchanged[100100] = {0};
	long long int changed[100100] = {0};
	long long int a = 0; long long int b = 0;
	long long int index = 0;
	for (int i = 1; i <= n; i++) {
		scanf("%lli", &b);
		if (index % 2 == 0) {
			unchanged[i] = b - a;
			changed[i] = 0;
		} else {
			changed[i] = b - a;
			unchanged[i] = 0;
		}
		index++;
		a = b;
	}
	if (index % 2 == 0) {
		unchanged[n + 1] = M - a;
	} else {
		changed[n + 1] = M - a;
	}

	long long int max = 0;
	long long int unchanged_sum[100100] = {0};
	long long int changed_sum[100100] = {0};

	long long int memo = 0;
	long long int memo2 = 0;
	for (int i = 1; i <= n + 1; i++) {
	    memo += unchanged[i];
	    unchanged_sum[i] = memo;
	    memo2 += changed[n + 2 - i];
	    changed_sum[n + 2 - i] = memo2;
	}
	max = unchanged_sum[n+1];
	long long int temp = 0;
	for (int i = n + 1; i >= 1; i--) {
		temp = 0;
		if (unchanged[i] >= 2) {
			temp += unchanged_sum[i];
			temp += changed_sum[i + 1];
			temp--;
		} else if (changed[i] >= 2) {
			temp += unchanged_sum[i - 1];
			temp += changed_sum[i];
			temp--;
		}
		if (max < temp) {
			max = temp;
		}
	}
	printf("%lli", max);
}


#include <bits/stdc++.h>
#include <cmath>
#include <vector>
#include <algorithm>

using namespace std;
#define INF 1e9+7
#define ll long long
#define tam 123456
#define fi first
#define se second
bool valid[tam];
bool valid2[tam];
string txt[tam];
string otro[tam];
ll valor[tam];
ll cuesta(string cambiar,string donde){
  if (cambiar==donde)
    return 0;
  return 1;
}
int main()
{
  ios::sync_with_stdio(false);cin.tie(0);
  ll n,m;
  cin>>n>>m;
  valor[0]=0;
  for (ll i = 1; i <=n; ++i)
  {
    cin>>valor[i];
  }
  n++;
  valor[n]=m;
  ll totprimero,totsegundo;
  totsegundo=totprimero=0;
  vector<ll> primero;
  vector<ll> segundo;
  for (ll i = 0; i <=n; ++i)
  {
    if (i%2==1)
    {
      primero.push_back((valor[i]-valor[i-1]));
      totprimero+=(valor[i]-valor[i-1]);
    }
    else
    {
      if (valor[i]==0)
      {
        segundo.push_back(0) ;
      }
      else{
        totsegundo+=valor[i]-valor[i-1];
        segundo.push_back(valor[i]-valor[i-1]);
      }
    }
  }

  ll maxx=totprimero;
  //cout<<maxx<<endl;
  if (primero[0]>1)
  {
    maxx=max(maxx,1+totsegundo);
  }
  if (segundo[segundo.size()-1]>1)
    maxx=max(maxx,totprimero+1);
  ll totizimpar,totizpar;
  totizpar=totizimpar=0;
  //cout<<totprimero<<" "<<totsegundo<<endl;
  for (ll i = 1; i < n; ++i)
  {
   // cout<<i<<endl;
    if (i%2==1)
    {
      if (primero[i/2]>1)
      maxx=max(maxx,primero[i/2]-1+totsegundo);//iz

      totizimpar+=primero[i/2];
      //cout<<primero[i/2]-1+totsegundo<<" "<<totizimpar+totsegundo-1<<endl;
      if (segundo[(i+1)/2]>1)
      maxx=max(maxx,totizimpar+totsegundo-1);
      totsegundo-=segundo[(i+1)/2];
    }
    else
    {
      //cout<<totizimpar<<endl;
      //cout<<totizimpar+1+totsegundo<<endl;
      if (segundo[i/2]>1)
      maxx=max(maxx,totizimpar+1+totsegundo);
      if (primero[(i+1)/2]>1)
      maxx=max(maxx,totizimpar+1+totsegundo);
    }
  }
  cout<<maxx<<endl;

}


#include <bits/stdc++.h>
#include <cmath>
#include <vector>
#include <algorithm>

using namespace std;
#define INF 1e9+7
#define ll long long
#define tam 123456
#define fi first
#define se second
bool valid[tam];
bool valid2[tam];
string txt[tam];
string otro[tam];
ll valor[tam];
ll cuesta(string cambiar,string donde){
  if (cambiar==donde)
    return 0;
  return 1;
}
int main()
{
  ios::sync_with_stdio(false);cin.tie(0);
  ll n,m;
  cin>>n>>m;
  valor[0]=0;
  for (ll i = 1; i <=n; ++i)
  {
    cin>>valor[i];
  }
  n++;
  valor[n]=m;
  ll totprimero,totsegundo;
  totsegundo=totprimero=0;
  vector<ll> primero;
  vector<ll> segundo;
  for (ll i = 0; i <=n; ++i)
  {
    if (i%2==1)
    {
      primero.push_back((valor[i]-valor[i-1]));
      totprimero+=(valor[i]-valor[i-1]);
    }
    else
    {
      if (valor[i]==0)
      {
        segundo.push_back(0) ;
      }
      else{
        totsegundo+=valor[i]-valor[i-1];
        segundo.push_back(valor[i]-valor[i-1]);
      }
    }
  }

  ll maxx=totprimero;
  //cout<<maxx<<endl;
  if (primero[0]>1)
  {
    maxx=max(maxx,1+totsegundo);
  }
  if (n%2==0)
  {
    if (segundo[segundo.size()-1]>1)
    {
      maxx=max(maxx,totprimero+1);
    }
  }
  ll totizimpar,totizpar;
  totizpar=totizimpar=0;
  //cout<<totprimero<<" "<<totsegundo<<endl;
  for (ll i = 1; i < n; ++i)
  {
   // cout<<i<<endl;
    if (i%2==1)
    {
      if (primero[i/2]>1)
      maxx=max(maxx,primero[i/2]-1+totsegundo);//iz

      totizimpar+=primero[i/2];
      //cout<<primero[i/2]-1+totsegundo<<" "<<totizimpar+totsegundo-1<<endl;
      if (segundo[(i+1)/2]>1)
      maxx=max(maxx,totizimpar+totsegundo-1);
      totsegundo-=segundo[(i+1)/2];
    }
    else
    {
      //cout<<totizimpar<<endl;
      //cout<<totizimpar+1+totsegundo<<endl;
      if (segundo[i/2]>1)
      maxx=max(maxx,totizimpar+1+totsegundo);
      if (primero[(i+1)/2]>1)
      maxx=max(maxx,totizimpar+1+totsegundo);
    }
  }
  cout<<maxx<<endl;

}


#include<bits/stdc++.h>
#define int long long int
#define fr(i,x,y) for(int i=x;i<y;i++)
#define f(n) for(int i=0;i<n;i++)
#define ff(m) for(int j=0;j<m;j++)
#define fff(l) for(int k=0;k<l;k++)
#define in insert
#define pb push_back
#define c(x) cout<<x<<endl;
#define d(x) cout<<x<<" ";
#define m(x) x%1000000007
#define inc int x=0,y=0,n=0,t=0,count=0,counter=0,q=0,p=0,g=0,h=0,l=0,u=0,sum=0,sum1=0,sum2=0,count1=0,count2=0;
#define inc1(n) int a[n],b[n];
using namespace std;
void ins(int a[],int n,int i=0){f(n) a[i]=i;} template<typename t>void ins(t a[],int n,t b=0){ f(n) a[i]=b;}
void print(int a[],int n){ f(n) d(a[i]); cout<<endl;} template <typename t>void print(t a[],int n){f(n) d(a[i]); cout<<endl;}
void po(int a[],int n){f(n){   cin>>a[i]; } } template <typename t>void po(t a[],int n){f(n){cin>>a[i];}}
//strlen(s.c_str());  set <int, greater<int>> s; numeric_limits<double>::max()
//---------------------------------------------------------------------------------------------------------------------------------------------

#define int int
int main(){
	#define int long long int
	int n,m;
	cin>>n>>m;
	int p;
	if((n+1)%2==0){
		p=0;
	}
	else{
		p=1;
	}

	int a[n+1];
	int b[(n+1)/2+1];
	int c[(n+1)/2];
	int sum=0;

	f(n){
		cin>>a[i];
		//if(i%2==1)sum+=a[i]-a[i-1];
	}
	a[n]=m;
	//print(a,n+1);
	f(n+1){
		if(i%2==1)sum+=a[i]-a[i-1];
	}
	//cout<<sum<<endl;

	int counter=0;
	int sum1=0;
	int max=numeric_limits<double>::min();
	f(n+1){
		if(i%2==0){
			if(i!=0)sum1+=a[i]-a[i-1];
			else sum1+=a[i];
			b[i/2]=sum1;
		}

	}
	f(n+1){
		if(i%2==1){

		c[i/2]=sum;
		sum-=a[i]-a[i-1];

		}
	}
//	print(b,(n+1)/2+1);
//	print(c,(n+1)/2);
	f((n+1)/2){

			int u=b[i/2]-1+c[i/2];
			if(max<u){
				max=u;
			}

	}
	if(true){
		if(max<sum1){
			max=sum1;
		}
	}
	cout<<max<<endl;

	return 0;
}


#include<bits/stdc++.h>
#define int long long int
#define fr(i,x,y) for(int i=x;i<y;i++)
#define f(n) for(int i=0;i<n;i++)
#define ff(m) for(int j=0;j<m;j++)
#define fff(l) for(int k=0;k<l;k++)
#define in insert
#define pb push_back
#define c(x) cout<<x<<endl;
#define d(x) cout<<x<<" ";
#define m(x) x%1000000007
#define inc int x=0,y=0,n=0,t=0,count=0,counter=0,q=0,p=0,g=0,h=0,l=0,u=0,sum=0,sum1=0,sum2=0,count1=0,count2=0;
#define inc1(n) int a[n],b[n];
using namespace std;
void ins(int a[],int n,int i=0){f(n) a[i]=i;} template<typename t>void ins(t a[],int n,t b=0){ f(n) a[i]=b;}
void print(int a[],int n){ f(n) d(a[i]); cout<<endl;} template <typename t>void print(t a[],int n){f(n) d(a[i]); cout<<endl;}
void po(int a[],int n){f(n){   cin>>a[i]; } } template <typename t>void po(t a[],int n){f(n){cin>>a[i];}}
//strlen(s.c_str());  set <int, greater<int>> s; numeric_limits<double>::max()
//---------------------------------------------------------------------------------------------------------------------------------------------

#define int int
int main(){
	#define int long long int
	int n,m;
	cin>>n>>m;
	int p;
	if((n+1)%2==0){
		p=0;
	}
	else{
		p=1;
	}

	int a[n+1];
	int b[(n+1)/2];
	int c[(n+1)/2];
	int sum=0;

	f(n){
		cin>>a[i];
		//if(i%2==1)sum+=a[i]-a[i-1];
	}
	a[n]=m;
	//print(a,n+1);
	f(n+1){
		if(i%2==1)sum+=a[i]-a[i-1];
	}
	//cout<<sum<<endl;

	int counter=0;
	int sum1=0;
	int max=numeric_limits<double>::min();
	f(n+1){
		if(i%2==0){
			if(i!=0)sum1+=a[i]-a[i-1];
			else sum1+=a[i];
			b[i/2]=sum1;
		}

	}
	f(n+1){
		if(i%2==1){

		c[i/2]=sum;
		sum-=a[i]-a[i-1];

		}
	}
//	print(b,(n+1)/2+1);
//	print(c,(n+1)/2);
int v;
if(p==1){
	v=(n+1)/2;
}
else{
	v=(n+1)/2-1;
}
	f(min((n+1)/2,v)){

			int u=b[i/2]-1+c[i/2];
			if(max<u){
				max=u;
			}

	}
	if(true){
		if(max<sum1){
			max=sum1;
		}
	}
	if(n==1){
		cout<<a[1]-1;
	}
	else cout<<max<<endl;

	return 0;
}


#include<bits/stdc++.h>
#define int long long int
#define fr(i,x,y) for(int i=x;i<y;i++)
#define f(n) for(int i=0;i<n;i++)
#define ff(m) for(int j=0;j<m;j++)
#define fff(l) for(int k=0;k<l;k++)
#define in insert
#define pb push_back
#define c(x) cout<<x<<endl;
#define d(x) cout<<x<<" ";
#define m(x) x%1000000007
#define inc int x=0,y=0,n=0,t=0,count=0,counter=0,q=0,p=0,g=0,h=0,l=0,u=0,sum=0,sum1=0,sum2=0,count1=0,count2=0;
#define inc1(n) int a[n],b[n];
using namespace std;
void ins(int a[],int n,int i=0){f(n) a[i]=i;} template<typename t>void ins(t a[],int n,t b=0){ f(n) a[i]=b;}
void print(int a[],int n){ f(n) d(a[i]); cout<<endl;} template <typename t>void print(t a[],int n){f(n) d(a[i]); cout<<endl;}
void po(int a[],int n){f(n){   cin>>a[i]; } } template <typename t>void po(t a[],int n){f(n){cin>>a[i];}}
//strlen(s.c_str());  set <int, greater<int>> s; numeric_limits<double>::max()
//---------------------------------------------------------------------------------------------------------------------------------------------

#define int int
int main(){
	#define int long long int
	int n,m;
	cin>>n>>m;
	int p;
	if((n+1)%2==0){
		p=0;
	}
	else{
		p=1;
	}

	int a[n+1];
	int b[(n+1)/2+1];
	int c[(n+1)/2];
	int sum=0;

	f(n){
		cin>>a[i];
		//if(i%2==1)sum+=a[i]-a[i-1];
	}
	a[n]=m;
	//print(a,n+1);
	f(n+1){
		if(i%2==1)sum+=a[i]-a[i-1];
	}
	//cout<<sum<<endl;

	int counter=0;
	int sum1=0;
	int max=numeric_limits<double>::min();
	f(n+1){
		if(i%2==0){
			if(i!=0)sum1+=a[i]-a[i-1];
			else sum1+=a[i];
			b[i/2]=sum1;
		}

	}
	f(n+1){
		if(i%2==1){

		c[i/2]=sum;
		sum-=a[i]-a[i-1];

		}
	}
//	print(b,(n+1)/2+1);
//	print(c,(n+1)/2);
	f((n+1)/2){

			int u=b[i/2]-1+c[i/2];
			if(max<u){
				max=u;
			}

	}
	if(p==1){
		if(max<b[(n+1)/2]){
			max=b[(n+1)/2];
		}
	}
	cout<<max<<endl;

	return 0;
}


#include<bits/stdc++.h>
#define int long long int
#define fr(i,x,y) for(int i=x;i<y;i++)
#define f(n) for(int i=0;i<n;i++)
#define ff(m) for(int j=0;j<m;j++)
#define fff(l) for(int k=0;k<l;k++)
#define in insert
#define pb push_back
#define c(x) cout<<x<<endl;
#define d(x) cout<<x<<" ";
#define m(x) x%1000000007
#define inc int x=0,y=0,n=0,t=0,count=0,counter=0,q=0,p=0,g=0,h=0,l=0,u=0,sum=0,sum1=0,sum2=0,count1=0,count2=0;
#define inc1(n) int a[n],b[n];
using namespace std;
void ins(int a[],int n,int i=0){f(n) a[i]=i;} template<typename t>void ins(t a[],int n,t b=0){ f(n) a[i]=b;}
void print(int a[],int n){ f(n) d(a[i]); cout<<endl;} template <typename t>void print(t a[],int n){f(n) d(a[i]); cout<<endl;}
void po(int a[],int n){f(n){   cin>>a[i]; } } template <typename t>void po(t a[],int n){f(n){cin>>a[i];}}
//strlen(s.c_str());  set <int, greater<int>> s; numeric_limits<double>::max()
//---------------------------------------------------------------------------------------------------------------------------------------------

#define int int
int main(){
	#define int long long int
	int n,m;
	cin>>n>>m;
	int p;
	if((n+1)%2==0){
		p=0;
	}
	else{
		p=1;
	}

	int a[n+1];
	int b[(n+2)/2];
	int c[(n+1)/2];
	int sum=0;

	f(n){
		cin>>a[i];
		//if(i%2==1)sum+=a[i]-a[i-1];
	}
	a[n]=m;
	//print(a,n+1);
	f(n+1){
		if(i%2==1)sum+=a[i]-a[i-1];
	}
	//cout<<sum<<endl;

	int counter=0;
	int sum1=0;
	int max=numeric_limits<double>::min();
	f(n+1){
		if(i%2==0){
			if(i!=0)sum1+=a[i]-a[i-1];
			else sum1+=a[i];
			b[i/2]=sum1;
		}

	}
	f(n+1){
		if(i%2==1){

		c[i/2]=sum;
		sum-=a[i]-a[i-1];

		}
	}
	//print(b,(n+1)/2);
	//print(c,(n+1)/2);
int v;
if(p==1){
	v=(n+1)/2;
}
else{
	v=(n+2)/2;
}
	f(min((n+2)/2,v)){
		//cout<<"trh"<<endl;
			int u=b[i]-1+c[i];
			if(max<u){
				max=u;
			}

	}
	if(true){
		if(max<sum1){
			max=sum1;
		}
	}
 cout<<max<<endl;

	return 0;
}


#include<bits/stdc++.h>
#define int long long int
#define fr(i,x,y) for(int i=x;i<y;i++)
#define f(n) for(int i=0;i<n;i++)
#define ff(m) for(int j=0;j<m;j++)
#define fff(l) for(int k=0;k<l;k++)
#define in insert
#define pb push_back
#define c(x) cout<<x<<endl;
#define d(x) cout<<x<<" ";
#define m(x) x%1000000007
#define inc int x=0,y=0,n=0,t=0,count=0,counter=0,q=0,p=0,g=0,h=0,l=0,u=0,sum=0,sum1=0,sum2=0,count1=0,count2=0;
#define inc1(n) int a[n],b[n];
using namespace std;
void ins(int a[],int n,int i=0){f(n) a[i]=i;} template<typename t>void ins(t a[],int n,t b=0){ f(n) a[i]=b;}
void print(int a[],int n){ f(n) d(a[i]); cout<<endl;} template <typename t>void print(t a[],int n){f(n) d(a[i]); cout<<endl;}
void po(int a[],int n){f(n){   cin>>a[i]; } } template <typename t>void po(t a[],int n){f(n){cin>>a[i];}}
//strlen(s.c_str());  set <int, greater<int>> s; numeric_limits<double>::max()
//---------------------------------------------------------------------------------------------------------------------------------------------

#define int int
int main(){
	#define int long long int
	int n,m;
	cin>>n>>m;
	int p;
	if((n+1)%2==0){
		p=0;
	}
	else{
		p=1;
	}

	int a[n+1];
	int b[(n+1)/2];
	int c[(n+1)/2];
	int sum=0;

	f(n){
		cin>>a[i];
		//if(i%2==1)sum+=a[i]-a[i-1];
	}
	a[n]=m;
	//print(a,n+1);
	f(n+1){
		if(i%2==1)sum+=a[i]-a[i-1];
	}
	//cout<<sum<<endl;

	int counter=0;
	int sum1=0;
	int max=numeric_limits<double>::min();
	f(n+1){
		if(i%2==0){
			if(i!=0)sum1+=a[i]-a[i-1];
			else sum1+=a[i];
			b[i/2]=sum1;
		}

	}
	f(n+1){
		if(i%2==1){

		c[i/2]=sum;
		sum-=a[i]-a[i-1];

		}
	}
//	print(b,(n+1)/2+1);
//	print(c,(n+1)/2);
int v;
if(p==1){
	v=(n+1)/2;
}
else{
	v=(n+1)/2-1;
}
	f(min((n+1)/2,v)){

			int u=b[i/2]-1+c[i/2];
			if(max<u){
				max=u;
			}

	}
	if(true){
		if(max<sum1){
			max=sum1;
		}
	}
	cout<<max<<endl;

	return 0;
}


#include<bits/stdc++.h>
#define int long long int
#define fr(i,x,y) for(int i=x;i<y;i++)
#define f(n) for(int i=0;i<n;i++)
#define ff(m) for(int j=0;j<m;j++)
#define fff(l) for(int k=0;k<l;k++)
#define in insert
#define pb push_back
#define c(x) cout<<x<<endl;
#define d(x) cout<<x<<" ";
#define m(x) x%1000000007
#define inc int x=0,y=0,n=0,t=0,count=0,counter=0,q=0,p=0,g=0,h=0,l=0,u=0,sum=0,sum1=0,sum2=0,count1=0,count2=0;
#define inc1(n) int a[n],b[n];
using namespace std;
void ins(int a[],int n,int i=0){f(n) a[i]=i;} template<typename t>void ins(t a[],int n,t b=0){ f(n) a[i]=b;}
void print(int a[],int n){ f(n) d(a[i]); cout<<endl;} template <typename t>void print(t a[],int n){f(n) d(a[i]); cout<<endl;}
void po(int a[],int n){f(n){   cin>>a[i]; } } template <typename t>void po(t a[],int n){f(n){cin>>a[i];}}
//strlen(s.c_str());  set <int, greater<int>> s; numeric_limits<double>::max()
//---------------------------------------------------------------------------------------------------------------------------------------------

#define int int
int main(){
	#define int long long int
	int n,m;
	cin>>n>>m;
	int p;
	if((n+1)%2==0){
		p=0;
	}
	else{
		p=1;
	}

	int a[n+1];
	int b[(n+1)/2];
	int c[(n+1)/2];
	int sum=0;

	f(n){
		cin>>a[i];
		//if(i%2==1)sum+=a[i]-a[i-1];
	}
	a[n]=m;
	//print(a,n+1);
	f(n+1){
		if(i%2==1)sum+=a[i]-a[i-1];
	}
	//cout<<sum<<endl;

	int counter=0;
	int sum1=0;
	int max=numeric_limits<double>::min();
	f(n+1){
		if(i%2==0){
			if(i!=0)sum1+=a[i]-a[i-1];
			else sum1+=a[i];
			b[i/2]=sum1;
		}

	}
	f(n+1){
		if(i%2==1){

		c[i/2]=sum;
		sum-=a[i]-a[i-1];

		}
	}
//	print(b,(n+1)/2);
//	print(c,(n+1)/2);
int v;
if(p==1){
	v=(n+1)/2-1;
}
else{
	v=(n+1)/2;
}
	f(min((n+1)/2,v)){
		//cout<<"trh"<<endl;
			int u=b[i/2]-1+c[i/2];
			if(max<u){
				max=u;
			}

	}
	if(true){
		if(max<sum1){
			max=sum1;
		}
	}
 cout<<max<<endl;

	return 0;
}


#include <bits/stdc++.h>
using namespace std;
const int maxn = 1005;
const int inf = 2140000000;
int n, m, a[maxn], p[maxn];
int ans = 0;
int Try(int u) {
	int ret = p[n + 1];
	if (u % 2 == 0) {
		ret -= 2 * (p[n + 1] - p[u]);
		ret += m - a[u];
		ret += a[u] - (a[u - 1] + 1);
		if (a[u] - a[u - 1] <= 1) ret = -inf;
	} else {
		ret -= 2 * (p[n + 1] - p[u]);
		ret += m - a[u];
		ret -= 1;
		if (a[u] - a[u - 1] <= 1) ret = -inf;
	}
	return ret;
}
int main() {
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= n; ++i) scanf("%d", a + i);
	a[0] = 0, a[n + 1] = m;
	for (int i = 1; i <= n + 1; i += 2) {
		p[i - 1] = ans;
		ans += a[i] - a[i - 1];
		p[i] = ans;
	}
	if (p[n + 1] == 0) p[n + 1] = p[n];
	for (int i = 1; i <= n + 1; ++i) {
		ans = max(ans, Try(i));
	}
	printf("%d\n", ans);
	return 0;
}


#include <string>
#include <set>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <iostream>
#include <algorithm>
#include <fstream>
#include <stdlib.h>
#include <math.h>
#include <iomanip>
#include <queue>
#include <map>
#include <typeinfo>
using namespace std;

#define PI 3.1415926535897932384626

int array[100100];

int prefix_on[100100];
int prefix_off[100100];

int n, m;

bool left_open(int index)
{
	bool left_open = true;
	if(index == 0 and array[index] == 1)
		left_open = false;
	else if(index != 0 and array[index - 1] == array[index] - 1)
		left_open = false;
	return left_open;
}

bool right_open(int index){
	bool right_open = true;
	if(index == n - 1 and array[index] == m - 1)
		right_open = false;
	else if(index != 0 and array[index + 1] == array[index] + 1)
		right_open = false;
	return right_open;
}

bool is_avail(int index)
{
	return left_open(index) or right_open(index);
}

int main(void)
{
	//ifstream fin("__.in");
	//ofstream fout("__.out");

	cin >> n >> m;

	cin >> array[0];
	prefix_on[0] = array[0];
	prefix_off[0] = 0;

	int prev = array[0];
	for(int i = 1; i < n; i++)
	{
		cin >> array[i];

		if(i % 2 == 0)
		{
			prefix_on[i] = prefix_on[i - 1] + array[i] - prev;
			prefix_off[i] = prefix_off[i - 1];
		}
		else
		{
			prefix_on[i] = prefix_on[i - 1];
			prefix_off[i] = prefix_off[i - 1] + array[i] - prev;
		}

		prev = array[i];
	}
	prefix_on[n] = prefix_on[n - 1];
	prefix_off[n] = prefix_off[n - 1];

	if(n % 2 == 0)
	{
		prefix_on[n] += m - array[n - 1];
	}
	else
	{
		prefix_off[n] += m - array[n - 1];
	}

	/*for(int i = 0; i <= n; i++)
	{
		cout << prefix_on[i] << " ";
	}
	cout << endl;
	for(int i = 0; i <= n; i++)
	{
		cout << prefix_off[i] << " ";
	}
	cout << endl;*/

	int ans = 0;
	for(int i = 0; i < n; i++)
	{
		if(not(is_avail(i)))
			continue;
		//cout << prefix_on[i] << " " << (prefix_off[n] - prefix_off[i]) << endl;
		int result = prefix_on[i] + (prefix_off[n] - prefix_off[i]) - 1; // add on to the left, and off to the right

		ans = max(ans, result);
	}

	ans = max(ans, prefix_off[n] - 1); // flip immediately
	ans = max(ans, prefix_on[n]); // don't change

	cout << ans << endl;
}


#include<iostream>
#include<vector>

using namespace std;

int main()
{
    int n,m;
    cin>>n>>m;

    vector<int>v;
    v.push_back(0);
    int k;

    for(int i=0;i<n;i++)
    {
        cin>>k;
        v.push_back(k);
    }
    v.push_back(m);
    vector<int>v1(v.size()-1);
    int ct=0;
    for(int i=1;i<v.size();i++)
    {   if(ct==0)
       {v1[i-1]=v[i]-v[i-1];ct=1;}
     else
     {
         v1[i-1]=v[i-1]-v[i];ct=0;
     }

    }

    ct=-1;
    long sum=0;long val=0;
    for(int i=v1.size()-1;i>=0;i--)
    {
        val+=v1[i];
        if(val<sum)
        {
            sum=val;
            ct=i;
        }
    }

    sum=0;
    if(ct==-1)
    {
        for(int i=0;i<v1.size();i++)
        {
            if(v1[i]>0)
                sum+=v1[i];
        }
    }
    else
    {
        for(int i=ct;i<v1.size();i++)
        {
            v1[i]*=-1;
        }

        for(int i=0;i<v1.size();i++)
            if(v1[i]>0)
                sum+=v1[i];
        sum--;
    }

    cout<<sum<<endl;

    return 0;
}


#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <algorithm>
#include <iostream>
#include <map>
#define maxn 100010
#define ll long long
#define ins 10000000007
using namespace std;
int main ()
{
	int a[maxn],b[maxn];
	int n,m;
	ll sum=0;
	int vi[maxn]={0};
	scanf ("%d%d",&n,&m);
	for (int i=1;i<=n;i++)
		cin>>a[i];
	b[1]=a[1];
	for (int i=1;i<n;i++)
		b[i+1]=a[i+1]-a[i];
	b[n+1]=m-a[n];
	vi[1]=b[1];
	for (int i=3;i<=n+1;i+=2)
		vi[i]=vi[i-2]+b[i];
	int nn=(n+1)/2*2;
	vi[nn]=b[nn];
	for (int i=nn-2;i>=2;i-=2)
		vi[i]=vi[i+2]+b[i];
	int ans;
	if (n%2==0) ans=vi[n+1];
	else ans=vi[n]+b[n+1]-1;
	ans=max(b[1]-1+vi[2],ans);
//	for (int i=1;i<=n+1;i++)
	//	cout<<b[i]<<endl;
//	for (int i=1;i<=n+1;i++)
//		cout<<vi[i]<<endl;
	for  (int i=2;i<=n;i++)
	{
		ans=max(ans,vi[i/2*2-1]+b[i]-1+vi[2+i/2*2]);
	}
	cout<<ans<<endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define F(i,a,b) for(int i=a;i<=(b);++i)
#define F2(i,a,b) for(int i=a;i<(b);++i)
#define dF(i,a,b) for(int i=a;i>=(b);--i)
#define dF2(i,a,b) for(int i=a;i>(b);--i)
#define eF(i,u) for(int i=h[u];i;i=nxt[i])
#define ll long long
#define ld double
typedef pair<int,int> pii;
inline int Gcd(int X,int Y){return Y?Gcd(Y,X%Y):X;}
inline ll Gcd(ll X,ll Y){return Y?Gcd(Y,X%Y):X;}
inline int Pow(int base,ll exp,int _mod){if(!(base%=_mod))return 0;int _ans=1;for(;exp;exp>>=1,base=(ll)base*base%_mod)exp&1?_ans=(ll)_ans*base%_mod:0;return _ans;}
inline ll Pow(ll base,ll exp,ll _mod){if(!(base%=_mod))return 0;ll _ans=1;for(;exp;exp>>=1,base=base*base%_mod)exp&1?_ans=_ans*base%_mod:0;return _ans;}
const int INF=0x3f3f3f3f;

int n,M;
int a[100005],b[100005],c[100005];

int main(){
	scanf("%d%d",&n,&M);
	F(i,1,n) scanf("%d",a+i); a[n+1]=M; ++n;
	dF(i,n,1) a[i]=a[i]-a[i-1];
	//奇数位ok
	F(i,1,n) b[i]=b[i-1]+(i&1?a[i]:0);
	dF(i,n-1,0) c[i]=c[i+1]+(i&1?a[i+1]:0);
	int A=b[n];
	F(i,1,n){
		if(i&1){
			int C=b[i]-1+c[i];
			A=max(A,C);
		}
		else{
			int C=b[i-1]+(a[i]-1)+c[i];
			A=max(A,C);
		}
	} printf("%d",A);
	return 0;
}


//luogu
#include<bits/stdc++.h>
using namespace std;
#define F(i,a,b) for(int i=a;i<=(b);++i)
#define F2(i,a,b) for(int i=a;i<(b);++i)
#define dF(i,a,b) for(int i=a;i>=(b);--i)
#define dF2(i,a,b) for(int i=a;i>(b);--i)
#define eF(i,u) for(int i=h[u];i;i=nxt[i])
#define ll long long
#define ld double
typedef pair<int,int> pii;
inline int Gcd(int X,int Y){return Y?Gcd(Y,X%Y):X;}
inline ll Gcd(ll X,ll Y){return Y?Gcd(Y,X%Y):X;}
inline int Pow(int base,ll exp,int _mod){if(!(base%=_mod))return 0;int _ans=1;for(;exp;exp>>=1,base=(ll)base*base%_mod)exp&1?_ans=(ll)_ans*base%_mod:0;return _ans;}
inline ll Pow(ll base,ll exp,ll _mod){if(!(base%=_mod))return 0;ll _ans=1;for(;exp;exp>>=1,base=base*base%_mod)exp&1?_ans=_ans*base%_mod:0;return _ans;}
const int INF=0x3f3f3f3f;

int n,M;
int a[100005],b[100005],c[100005];

int main(){
	scanf("%d%d",&n,&M);
	F(i,1,n) scanf("%d",a+i); a[n+1]=M; ++n;
	dF(i,n,1) a[i]=a[i]-a[i-1];
	//奇数位ok
	F(i,1,n) b[i]=b[i-1]+(i&1?a[i]:0);
	dF(i,n-1,0) c[i]=c[i+1]+(i&1?a[i+1]:0);
	int A=b[n];
	F(i,1,n){
		if(i&1){
			int C=b[i]-1+c[i];
			A=max(A,C);
		}
		else{
			int C=b[i-1]+(a[i]-1)+c[i];
			A=max(A,C);
		}
	} printf("%d",A);
	return 0;
}


#include <iostream>
#include <vector>

using namespace std;

int main() {
    unsigned int n = 0, m = 0;
    vector<unsigned int> a;
    unsigned int num = 0;

    a.push_back(0);
    cin >> n >> m;
    for (int i = 0; i < n; i++) {
        cin >> num;
        a.push_back(num);
    }
    a.push_back(m);

    unsigned int w[100002];
    for (int i = 1; i < a.size(); i++) {
        w[i] = a[i] - a[i-1];
    }

    unsigned long long sum[100002];
    for (int i = 1; i <= n + 1; i += 2) {
        sum[0] += w[i];
        sum[1] += w[i+1];
    }

    for (int i = 3; i <= n + 1; i += 2) {
        sum[i] = sum[i-1] = sum[i-2] - w[i-1] + w[i-2];
    }

    /*
    for (int i = 0; i <= n + 1; i++) {
        cout << sum[i] << " ";
    }
    cout << endl;
    */

    unsigned long long max = sum[0];
    for (int i = 1; i <= n + 1; i++) {
        if (a[i] - a[i-1] < 2) {
            continue;
        }

        if (i % 2 == 1) {
            unsigned long long tmp = sum[i] + a[i] - 1 - a[i-1];
            if (tmp > max) {
                max = tmp;
            }
        }
        else {
            unsigned long long tmp = sum[i] + a[i] - (a[i-1] + 1);
            if (tmp > max) {
                max = tmp;
            }
        }
    }

    cout << max << endl;

    return 0;
}


#include <iostream>
#include <list>

using namespace std;

unsigned long long sumLightUp(list<unsigned int> &a) {
	unsigned int lastNum = 0;
	unsigned long long lightUpSum = 0;
	bool on = true;

	for (list<unsigned int>::iterator iter2 = a.begin(); iter2 != a.end(); iter2++) {
		if (lastNum == *iter2) {
			return 0;
		}

		if (on) {
			if (iter2 == a.begin()) {
				lightUpSum += (*iter2);
			}
			else {
				lightUpSum += (*iter2) - lastNum;
			}
		}

		on = !on;
		lastNum = *iter2;

		// cout << *iter2 << " ";
	}
	// cout << endl;
	// cout << "sum = " << lightUpSum << endl;

	return lightUpSum;
}

int main() {
	unsigned int n = 0, m = 0;
	list<unsigned int> a;
	unsigned int num = 0;

	cin >> n >> m;
	for (int i = 0; i < n; i++) {
		cin >> num;
		a.push_back(num);
	}
	a.push_back(m);

	unsigned long long max = sumLightUp(a);

	for (list<unsigned int>::iterator iter = a.begin(); iter != a.end(); iter++) {
		unsigned int num = *iter;

		if (num > 1) {
			list<unsigned int>::iterator newIter = a.insert(iter, num - 1);
			unsigned long long lightUpSum = sumLightUp(a);

			if (lightUpSum > max) {
				max = lightUpSum;
			}

			a.erase(newIter);
		}

		if (num + 1 < m) {
			iter++;
			list<unsigned int>::iterator newIter = a.insert(iter, num + 1);
			unsigned long long lightUpSum = sumLightUp(a);

			if (lightUpSum > max) {
				max = lightUpSum;
			}

			a.erase(newIter);
			iter--;
		}
	}

	cout << max << endl;

	return 0;
}


#include <iostream>
#include <list>

using namespace std;

unsigned long long sumLightUp(list<unsigned int> &a) {
	unsigned int lastNum = 0;
	unsigned long long lightUpSum = 0;
	bool on = true;

	for (list<unsigned int>::iterator iter2 = a.begin(); iter2 != a.end(); iter2++) {
		if (on) {
			if (iter2 == a.begin()) {
				lightUpSum += (*iter2);
			}
			else {
				lightUpSum += (*iter2) - lastNum;
			}
		}

		on = !on;
		lastNum = *iter2;
	}

	return lightUpSum;
}

int main() {
	unsigned int n = 0, m = 0;
	list<unsigned int> a;
	unsigned int num = 0;

	cin >> n >> m;
	for (int i = 0; i < n; i++) {
		cin >> num;
		a.push_back(num);
	}
	a.push_back(m);

	unsigned long long max = sumLightUp(a);

	for (list<unsigned int>::iterator iter = a.begin(); iter != a.end(); iter++) {
		unsigned int num = *iter;
		list<unsigned int>::iterator newIter = a.insert(iter, num - 1);
		unsigned long long lightUpSum = sumLightUp(a);

		if (lightUpSum > max) {
			max = lightUpSum;
		}

		a.erase(newIter);

		iter++;
		newIter = a.insert(iter, num + 1);

		if (lightUpSum > max) {
			max = lightUpSum;
		}

		a.erase(newIter);

		iter--;
	}

	cout << max << endl;

	return 0;
}