/*
疯狂的牛牛
n个隔间 c头牛
使每两头牛之间的最小距离最大化
思路:
转化为判定性问题
判断间距d是否可行;对间距d采取二分策略
*/
#include<stdio.h>
#include<algorithm>
using namespace std;
const int MAXN = 1e5 + 10;
int arr[MAXN];
bool judge(int n, int m, int distance){
int current = arr[0];//第一头牛放在第一个位置
int number = 1;//记录放的牛的数量
for(int i = 1;i < n; ++i){
if(arr[i] - current >= distance){
number++;
current = arr[i];
}
if(number >= m){
return true;
}
}
return false;
}
int main()
{
int n,m;
while(scanf("%d%d",&n,&m) != EOF){
for(int i = 0;i < n; ++i){
scanf("%d",&arr[i]);
}
sort(arr,arr+n);
int left = 1;
int right = arr[n-1] - arr[0];
while(left <= right){
int middle = (left+right)/2;
if(judge(n,m,middle)){
left = middle + 1;
}
else{
right = middle - 1;
}
}
printf("%d",right);
}
return 0;
}