Building a Tall Barn

Assign K cows to N ordered floors, each with work a_i, so each floor gets at least one cow; minimize the sum of a_i/c_i over valid allocations, rounded to nearest integer.

Hard9GreedyHeapMathBinary searchNo attempts yetTime limit2sMemory limit512 MB

Problem

Farmer John is building a brand new NN-story barn with the help of his KK cows (1NK10121 \le N \le K \le 10^{12} and N105N \le 10^5). To build it as quickly as possible, he needs your help to figure out how to allocate work among the cows.

Each cow must be assigned to work on exactly one of the NN floors of the barn, and each floor must have at least one cow assigned to it. The ii-th floor requires aia_i units of total work, and each cow completes one unit of work per hour, so if cc cows work on floor ii, it is completed in ai/ca_i/c units of time. For safety reasons, floor ii must be completed before construction can begin on floor i+1i+1.

Compute the minimum total time in which the barn can be completed if the cows are allocated to floors optimally. Output this number rounded to the nearest integer. It is guaranteed that the exact answer is more than 0.1 away from the boundary between two integers.

Input

The first line contains NN and KK.

Each of the next NN lines contains one of a1,a2,,aNa_1, a_2, \ldots, a_N, in order. Each value is a positive integer of at most 101210^{12}.

Output

Print the minimum time required to build the barn, rounded to the nearest integer.