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