// Arup Guha
// 7/3/2013
// Solution to 2013 World Finals Problem F: Low Power

import java.util.*;

public class power {

	public static void main(String[] args) {

		Scanner stdin = new Scanner(System.in);

		int n = stdin.nextInt();
		int k = stdin.nextInt();

		int[] vals = new int[2*n*k];
		for (int i=0; i<vals.length; i++)
			vals[i] = stdin.nextInt();

		// Set up our greedy algorithm - we must take the first difference of the sorted values.
		// From there, we keep a TreeSet of all candidates and a HashSet of forbidden candidates, and
		// take the best answer after reading in 2k more items.
		Arrays.sort(vals);
		HashSet<Integer> forbidden = new HashSet<Integer>();
		TreeSet<pair> notUsed = new TreeSet<pair>();
		int answer = vals[1] - vals[0];
		forbidden.add(1);

		// Fill in each difference (between pairs of mins on a chip)
		for (int i=1; i<n; i++) {

			// Add all contending pairs.
			for (int j=2*(i-1)*k+1; j<=2*i*k; j++)
				notUsed.add(new pair(vals[j+1]-vals[j],j));

			// Get the lowest difference that isn't forbidden.
			pair next = notUsed.pollFirst();
			while(forbidden.contains(next.index)) {
				next = notUsed.pollFirst();
			}

			// Update our maximum difference, if necessary.
			if (next.diff > answer)
				answer = next.diff;

			// These two can't be used.
			forbidden.add(next.index-1);
			forbidden.add(next.index+1);
		}

		// Here's our answer!
		System.out.println(answer);
	}
}

class pair implements Comparable<pair> {

	public int diff;
	public int index;

	public pair(int d, int i) {
		diff = d;
		index = i;
	}

	public int compareTo(pair other) {
		if (this.diff != other.diff)
			return this.diff - other.diff;
		return this.index - other.index;
	}
}