#ABC252F. [ABC252F] Bread

[ABC252F] Bread

Score : 500500 points

Problem Statement

We have a loaf of bread of length LL, which we will cut and distribute to NN children. The ii-th child (1iN)(1\leq i\leq N) wants a loaf of length AiA_i.

Now, Takahashi will repeat the operation below to cut the loaf into lengths A1,A2,,ANA_1, A_2, \ldots, A_N for the children.

Choose a loaf of length kk and an integer xx between 11 and k1k-1 (inclusive). Cut the loaf into two loaves of length xx and kxk-x. This operation incurs a cost of kk regardless of the value of xx.

Each child ii must receive a loaf of length exactly AiA_i, but it is allowed to leave some loaves undistributed.

Find the minimum cost needed to distribute loaves to all children.

Constraints

  • 2N2×1052 \leq N \leq 2\times 10^5
  • 1Ai1091\leq A_i\leq 10^9
  • A1+A2++ANL1015A_1+A_2+\cdots+A_N\leq L\leq 10^{15}
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:

NN LL

A1A_1 A2A_2 \ldots ANA_N

Output

Print the minimum cost needed to distribute loaves to all children.

5 7
1 2 1 2 1
16

Takahashi can cut the loaf for the children as follows.

  • Choose the loaf of length 77 and x=3x=3, cutting it into loaves of length 33 and 44 for a cost of 77.
  • Choose the loaf of length 33 and x=1x=1, cutting it into loaves of length 11 and 22 for a cost of 33. Give the former to the 11-st child.
  • Choose the loaf of length 22 and x=1x=1, cutting it into two loaves of length 11 for a cost of 22. Give them to the 33-rd and 55-th children.
  • Choose the loaf of length 44 and x=2x=2, cutting it into two loaves of length 22 for a cost of 44. Give them to the 22-nd and 44-th children.

This incurs a cost of 7+3+2+4=167+3+2+4=16, which is the minimum possible. There will be no leftover loaves.

3 1000000000000000
1000000000 1000000000 1000000000
1000005000000000

Note that each child ii must receive a loaf of length exactly AiA_i.