// Arup Guha
// 2/25/2017
// Solution to 2017 January USACO Platinum Problem: Building a Tall Barn

import java.util.*;
import java.io.*;

public class tallbarn {

	public static int numFloors;
	public static long numCows;
	public static long[] workPerFloor;

	public static void main(String[] args) throws Exception {

		// Open file.
		BufferedReader stdin = new BufferedReader(new FileReader("tallbarn.in"));
		StringTokenizer tok = new StringTokenizer(stdin.readLine());

		numFloors = Integer.parseInt(tok.nextToken());
		numCows = Long.parseLong(tok.nextToken());

		// Read in the data.
		workPerFloor = new long[numFloors];
		for (int i=0; i<numFloors; i++)
			workPerFloor[i] = Long.parseLong(stdin.readLine().trim());

		// Set up binary search over "utility" of adding a cow.
		double low = 0, high = 1e12;
		double res = 1e12;

		// Run a binary search.
		for (int i=0; i<150; i++) {

			// Try this benefit point.
			double mid = (low+high)/2;
			long numC = solve(mid);

			// We have enough cows, so we can lower the benefit point.
			if (numC <= numCows)
				high = mid;

			// We don't have enough cows, so increase it.
			else
				low = mid;
		}

		// Ta da!
		PrintWriter out = new PrintWriter(new FileWriter("tallbarn.out"));
		out.printf("%.0f\n", getMinTime(high));
		out.close();
		stdin.close();
	}

	// Returns the number of cows we use if we insist that each cow adds benefit benefit or better.
	public static long solve(double benefit) {

		long cowsUsed = 0;

		// Go through each floor and add the number of cows equal to what you need to keep the benefit high enough.
		for (int i=0; i<numFloors; i++) {
			long add = (long)(.5 + Math.sqrt(1+4*workPerFloor[i]/benefit)/2);
			cowsUsed += (add);
		}

		return cowsUsed;
	}

	public static double getMinTime(double benefit) {
		long cowsUsed = 0;
		double[] next = new double[numFloors];
		double timeUsed = 0;

		// Re-run solve with optimal benefit, calculating how many extra cows there are and the extra benefit for adding 1 more cow to each floor.
		for (int i=0; i<numFloors; i++) {
			long add = (long)(.5 + Math.sqrt(1+4*workPerFloor[i]/benefit)/2);
			cowsUsed += add;
			timeUsed += 1.0*workPerFloor[i]/add;
			next[i] = workPerFloor[i]*(1.0/add - 1.0/(add+1));
		}

		// Sort this, we want to take most advantage of floors left.
		Arrays.sort(next);

		// Here is the number of extra cows.
		long cowsleft = numCows - cowsUsed;

		// Subtract out the benefit of time with each extra cow.
		for (int i=numFloors-1,j=0; j<cowsleft && i>=0; j++,i--)
			timeUsed -= next[i];

		return timeUsed;
	}
}