#include<cstdio>
#include<algorithm>
using namespace std;
int n,m,a[200005],ans;
bool check(int mid){
	for(int i=mid<<1|1,j=n+n;i<j;++i,--j)
		if(a[i]+a[j]<m)
			return false;
	return true;
}
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n+n;++i)scanf("%d",&a[i]);
	sort(a+1,a+n+n+1);
	int l=0,r=n-1,res=n;
	while(l<=r){
		int mid=l+r>>1;
		if(check(mid))res=mid,r=mid-1;
		else l=mid+1;
	}
	for(int i=1,j=res<<1;i<j;++i,--j)ans=max(ans,a[i]+a[j]);
	for(int i=res<<1|1,j=n+n;i<j;++i,--j)ans=max(ans,a[i]+a[j]-m);
	printf("%d\n",ans);
	return 0;
}
