#include <bits/stdc++.h>
using namespace std;
int64_t n, K, ans;
vector<int64_t> v, previous;
vector<bool> L;
int main() {
  scanf("%I64d%I64d", &n, &K);
  v.resize(n + 1);
  previous.resize(n + 1);
  for (int64_t i = 1; i <= n; i++) scanf("%I64d", &v[i]);
  sort(v.begin() + 1, v.end());
  int64_t first = 0, last = v[n] - v[1], center;
  while (first <= last) {
    center = (first + last) / 2;
    fill(previous.begin(), previous.end(), 0);
    for (int64_t i = K; i <= n; i++)
      if (v[i] - v[previous[i - K] + 1] < center)
        previous[i] = i;
      else
        previous[i] = previous[i - 1];
    if (previous[n] == n)
      last = center - 1;
    else
      first = center + 1;
  }
  ans = first - 1;
  printf("%I64d", ans);
  return 0;
}
