#include <iostream>
#include <vector>
#include <algorithm>
#define all(a) a.begin(),a.end()
using namespace std;

int main() {
	int n, m;
	cin >> n >> m;
	vector<int> a(2 * n);
	for (int i = 0; i < 2 * n; i++) cin >> a[i];
	sort(all(a));
	int l = 0;
	for (int i = 2 * n - 1; i > l; i--) {
		while (a[i] + a[l] < m && l < i - 1) l++;
		if (a[i] + a[l] >= m) {
			a[i] -= m; l++;
		}
	}
	sort(all(a));
	int ans = 0;
	for (int i = 0; i < n; i++) ans = max(ans, a[i] + a[2 * n - 1 - i]);
	cout << ans << endl;
}