#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define db double
#define pint pair<int,int>
#define mk(x,y) make_pair(x,y)
#define fir first
#define sec second
#define Rep(x,y,z) for(int x=y;x<=z;x++)
#define Red(x,y,z) for(int x=y;x>=z;x--)
using namespace std;
const int MAXN=2e5+5;
char buf[1<<12],*pp1=buf,*pp2=buf,nc;int ny;
inline char gc() {return pp1==pp2&&(pp2=(pp1=buf)+fread(buf,1,1<<12,stdin),pp1==pp2)?EOF:*pp1++;}
//inline char gc(){return getchar();}
inline int read(){
	int x=0;for(ny=1;nc=gc(),(nc<48||nc>57)&&nc!=EOF;)if(nc==45)ny=-1;if(nc<0)return nc;
	for(x=nc-48;nc=gc(),47<nc&&nc<58&&nc!=EOF;x=(x<<3)+(x<<1)+(nc^48));return x*ny;
}int n,m,a[MAXN],ans=1e9;
inline bool chk(int k){
	int tmp=0;
	Rep(i,2*k+1,n+k){
		if(a[2*(n+k)-i+1]+a[i]<m)return 0;
		tmp=max(tmp,a[2*(n+k)-i+1]+a[i]-m);
	}Rep(i,1,k)tmp=max(tmp,a[i]+a[2*k-i+1]);
	return ans=min(ans,tmp),1;
}
int main(){
//	freopen("std.in","r",stdin);
//	freopen("std.out","w",stdout);
	n=read(),m=read();Rep(i,1,2*n)a[i]=read();sort(a+1,a+2*n+1);
	for(int mid,l=0,r=n;l<=r;)chk(mid=l+r>>1)?r=mid-1:l=mid+1;
	cout<<ans<<'\n';
	return 0;
}



### Prompt

Construct a Cpp code solution to the problem outlined:

Let M be a positive integer.

You are given 2 N integers a_1, a_2, \ldots, a_{2 N}, where 0 \leq a_i < M for each i.

Consider dividing the 2 N integers into N pairs. Here, each integer must belong to exactly one pair.

We define the ugliness of a pair (x, y) as (x + y) \mod M. Let Z be the largest ugliness of the N pairs. Find the minimum possible value of Z.

Constraints

* All values in input are integers.
* 1 \leq N \leq 10^5
* 1 \leq M \leq 10^9
* 0 \leq a_i < M

Input

Input is given from Standard Input in the following format:


N M
a_1 a_2 \cdots a_{2N}


Output

Print the minimum possible value of Z, where Z is the largest ugliness of the N pairs.

Examples

Input

3 10
0 2 3 4 5 9


Output

5


Input

2 10
1 9 1 9


Output

0

### Response

```cpp
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define db double
#define pint pair<int,int>
#define mk(x,y) make_pair(x,y)
#define fir first
#define sec second
#define Rep(x,y,z) for(int x=y;x<=z;x++)
#define Red(x,y,z) for(int x=y;x>=z;x--)
using namespace std;
const int MAXN=2e5+5;
char buf[1<<12],*pp1=buf,*pp2=buf,nc;int ny;
inline char gc() {return pp1==pp2&&(pp2=(pp1=buf)+fread(buf,1,1<<12,stdin),pp1==pp2)?EOF:*pp1++;}
//inline char gc(){return getchar();}
inline int read(){
	int x=0;for(ny=1;nc=gc(),(nc<48||nc>57)&&nc!=EOF;)if(nc==45)ny=-1;if(nc<0)return nc;
	for(x=nc-48;nc=gc(),47<nc&&nc<58&&nc!=EOF;x=(x<<3)+(x<<1)+(nc^48));return x*ny;
}int n,m,a[MAXN],ans=1e9;
inline bool chk(int k){
	int tmp=0;
	Rep(i,2*k+1,n+k){
		if(a[2*(n+k)-i+1]+a[i]<m)return 0;
		tmp=max(tmp,a[2*(n+k)-i+1]+a[i]-m);
	}Rep(i,1,k)tmp=max(tmp,a[i]+a[2*k-i+1]);
	return ans=min(ans,tmp),1;
}
int main(){
//	freopen("std.in","r",stdin);
//	freopen("std.out","w",stdout);
	n=read(),m=read();Rep(i,1,2*n)a[i]=read();sort(a+1,a+2*n+1);
	for(int mid,l=0,r=n;l<=r;)chk(mid=l+r>>1)?r=mid-1:l=mid+1;
	cout<<ans<<'\n';
	return 0;
}



```