public static void main(String[] args) throws NumberFormatException, IOException {
		int numPackets = Integer.parseInt(in.readLine());
		int numKids = Integer.parseInt(in.readLine());
		int[] packets = new int[numPackets];

		for(int i = 0; i < numPackets; i ++)
		{
			packets[i] = Integer.parseInt(in.readLine());
		}

		int unfairness = Integer.MAX_VALUE;

		unfairness = findUnfairness(numKids, packets);

		System.out.println(unfairness);
	}