#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define mem(x,v) memset(x,v,sizeof(x))
#define Rep(i,a,b) for(register int i=(a);i<=int(b);++i)
#define rep(i,a,b) for(register int i=(a);i<int(b);++i)
#define Dep(i,a,b) for(register int i=(a);i>=int(b);--i)
#define gc getchar
#define pc putchar
#define fi first
#define se second
inline ll read(){
    ll x=0,f=1;char c=gc();
    for(;!isdigit(c);c=gc())if(c=='-')f=-1;
    for(;isdigit(c);c=gc())x=(x<<1)+(x<<3)+(c^48);
    return x*f;
}
inline void write(ll x){if(x<0)x=-x,pc('-');if(x>=10)write(x/10);putchar(x%10+'0');}
inline void writeln(ll x){write(x);pc('\n');}
inline void wri(ll x){write(x);pc(' ');}
const int maxn = 2e5+233;;
//神仙结论https://img.atcoder.jp/agc032/editorial.pdf 
int a[maxn],n,m;
bool check(int k){
	k *= 2;
	rep(i,k,k+(2*n-k)/2)
		if(a[i]+a[2*n-(i-k)-1]<m) return false;
	return true;
}
int main(){
	n = read(),m = read();
	rep(i,0,n*2) a[i] = read();
	sort(a,a+2*n);
	int l = 0,r = n,ans = n;
	while(l <= r){
		int mid = (l + r) >> 1;
		if(check(mid)){
			ans = mid;
			r = mid - 1;
		} else l = mid + 1;
	}ans*=2;
	int mx = -1;
	rep(i,0,ans/2) mx=max(mx,a[i]+a[ans-i-1]);
	rep(i,ans,ans+(2*n-ans)/2) mx=max(mx,a[i]+a[2*n-(i-ans)-1]-m);
	writeln(mx);
	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>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define mem(x,v) memset(x,v,sizeof(x))
#define Rep(i,a,b) for(register int i=(a);i<=int(b);++i)
#define rep(i,a,b) for(register int i=(a);i<int(b);++i)
#define Dep(i,a,b) for(register int i=(a);i>=int(b);--i)
#define gc getchar
#define pc putchar
#define fi first
#define se second
inline ll read(){
    ll x=0,f=1;char c=gc();
    for(;!isdigit(c);c=gc())if(c=='-')f=-1;
    for(;isdigit(c);c=gc())x=(x<<1)+(x<<3)+(c^48);
    return x*f;
}
inline void write(ll x){if(x<0)x=-x,pc('-');if(x>=10)write(x/10);putchar(x%10+'0');}
inline void writeln(ll x){write(x);pc('\n');}
inline void wri(ll x){write(x);pc(' ');}
const int maxn = 2e5+233;;
//神仙结论https://img.atcoder.jp/agc032/editorial.pdf 
int a[maxn],n,m;
bool check(int k){
	k *= 2;
	rep(i,k,k+(2*n-k)/2)
		if(a[i]+a[2*n-(i-k)-1]<m) return false;
	return true;
}
int main(){
	n = read(),m = read();
	rep(i,0,n*2) a[i] = read();
	sort(a,a+2*n);
	int l = 0,r = n,ans = n;
	while(l <= r){
		int mid = (l + r) >> 1;
		if(check(mid)){
			ans = mid;
			r = mid - 1;
		} else l = mid + 1;
	}ans*=2;
	int mx = -1;
	rep(i,0,ans/2) mx=max(mx,a[i]+a[ans-i-1]);
	rep(i,ans,ans+(2*n-ans)/2) mx=max(mx,a[i]+a[2*n-(i-ans)-1]-m);
	writeln(mx);
	return 0;
}
```