#include <algorithm>
#include <bits/stdc++.h>
#define int long long
#define el '\n'
#define oo LLONG_MAX >> 2
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define pb push_back
#define pep_Guardiola                                                          \
  ios::sync_with_stdio(0);                                                     \
  cin.tie(0);                                                                  \
  cout.tie(0);
using namespace std;

signed main() {
  pep_Guardiola

      int n,
      k;
  cin >> n >> k;
  vector<int> a(n);
  for (auto &i : a)
    cin >> i;
  sort(all(a));
  auto ok = [&](int x) -> bool {
    int tmp = 0;
    for (int i = 0; i < n; i++)
      tmp += upper_bound(a.begin() + i + 1, a.end(), a[i] + x) - (a.begin() + i + 1);
    return tmp < k;
  };
  int l = 0, r = a[n - 1] - a[0];
  while (l <= r) {
    int mid = (r + l) >> 1;
    if (ok(mid))
      l = mid + 1;
    else
      r = mid - 1;
  }
  cout << ++r << el;
}