#include <bits/stdc++.h>   using namespace std;   const int maxn = 300000 + 5;   int a[maxn], dp[maxn];   int n, k;   bool ok_hack(int x) {     memset(dp, 0, sizeof(dp));     int last = 0;     for (int i = k; i <= n; i++) {       if (a[i] - a[dp[i - k] + 1] <= x) last = i;       dp[i] = last;     }     return dp[n] == n;   }   int main() {     scanf( %d%d , &n, &k);     for (int i = 1; i <= n; i++) scanf( %d , &a[i]);     sort(a + 1, a + n + 1);     a[0] = 0;     int l = 0, r = a[n] - a[1];     while (l < r) {       int mid = r + l >> 1;       if (ok_hack(mid))         r = mid;       else         l = mid + 1;     }     printf( %d n , l);     return 0;   }   