import java.util.*;
public class C{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int m = sc.nextInt();
double[] num = new double[n];
for(int i=0;i<n;i++){
num[i]=sc.nextDouble();
}
Arrays.sort(num);//从小到大排列
double maxSum = 0;
double minDifferValue = Double.MAX_VALUE;
for(int i=0;i<=n-m;i++){
double sum = 0;
//数组排好序后M为一组,一组差距值为这一 组末尾元素减这一组第一个
double differValue = num[i+m-1]-num[i]; //间隔值(只需计算每组最后一个减去每组第一)
for(int j = 0;j<m;j++){
sum+=num[j+i];//每组原值的总和
}
if(differValue<=minDifferValue){
maxSum = sum;
minDifferValue=differValue;
}
}
System.out.print(String.format("%.2f",maxSum)); //String.format()各个百分号处会被数据依次替换,此处"%.2f"为保留两位小数
}
}