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

const int N = 100005;
int n, M, a[2 * N];

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 b = 0;
	for (int i = 2 * n, j = 0; i; --i) {
		while (j < i && a[i] + a[j] < M) ++j;
		b = max(b, j + !(i - j & 1) - (2 * n - i));
	}
	int ans = 0;
	for (int i = b; i < 2 * n + b - i; ++i)
		ans = max(ans, a[i] + a[2 * n + b - i] - M);
	for (int i = 1; i < b - i; ++i)
		ans = max(ans, a[i] + a[b - i]);
	printf("%d\n", ans);
	return 0;
}
