#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
long long powmod(long long a, long long b) {
  long long res = 1;
  a %= mod;
  assert(b >= 0);
  for (; b; b >>= 1) {
    if (b & 1) res = res * a % mod;
    a = a * a % mod;
  }
  return res;
}
const int N = 301000;
int dp[N], sdp[N];
int n, k, x[N];
bool check(int p) {
  int l = 1;
  dp[0] = 1;
  sdp[1] = 1;
  for (int i = 1; i < n + 1; i++) {
    while (x[l] < x[i] - p) l++;
    if (l - 1 > i - k)
      dp[i] = 0;
    else
      dp[i] = !!(sdp[i - k + 1] - sdp[l - 1]);
    sdp[i + 1] = sdp[i] + dp[i];
  }
  return dp[n];
}
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 1; i < n + 1; i++) scanf("%d", x + i);
  sort(x + 1, x + n + 1);
  int l = -1, r = 1000000001;
  while (l + 1 < r) {
    int md = (l + r) >> 1;
    if (check(md))
      r = md;
    else
      l = md;
  }
  printf("%d\n", r);
}
