module main; import std; // 集合の分割を列挙する T[][][] partition(T)(T[] arr, int k) { T[][][] result; void backtrack(int start, int k, T[][] currentPartition) { if (k == 1) { result ~= currentPartition ~ [arr[start .. $]]; return; } foreach (i; start .. arr.length.to!int - k + 1) backtrack(i + 1, k - 1, currentPartition ~ [arr[start .. i + 1]]); } backtrack(0, k, []); return result; } void main() { // 入力 auto N = readln.chomp.to!int; auto K = readln.chomp.to!int; double[] num; foreach (_; 0 .. N) { num ~= readln.chomp.to!double; } // 答えの計算 double max = -1e10, min = 1e10; foreach (p; partition(num, K)) { foreach (e; p) { double m = e.mean; if (max < m) max = m; else if (min > m) min = m; } } // 答えの出力 writeln(ceil(max - min)); }