#Q190. 「一本通 5.6 练习 1」玩具装箱

「一本通 5.6 练习 1」玩具装箱

Description

Original source: HNOI 2008

Professor P is going to the Olympics, but he can't bear to part with his toys, so he decides to transport all of them to Beijing.

He uses his own compressor to pack them. This compressor can transform any item into one-dimensional form and place it into a special one-dimensional container. Professor P has N toys numbered from 11 to NN. After compression, the ii-th toy has a length of CiC_i.

For ease of organization, Professor P requires:

  • In a one-dimensional container, the toy numbers must be consecutive;
  • If a one-dimensional container holds multiple toys, a unit-length filler must be added between each pair of toys. Formally, if toys numbered from ii to jj (ij)(i\le j) are placed in the same container, the container length must be at least x=ji+k=ijCkx = j - i + \displaystyle\sum_{k=i}^{j} C_k.

The cost of making a container depends on its length. According to the professor's research, if the container length is xx, the production cost is (XL)2(X - L)^2, where LL is a constant.

Professor P doesn't care about the number of containers; he can make containers of any length, even exceeding LL. Find the minimum cost.

Input Format

The first line contains two integers NN and LL;
The next NN lines each contain an integer CiC_i.

Output Format

Output the minimum cost.

Sample 1

5 4
3
4
2
1
4

1

Data Range and Hints

For all data, 1N5×1041\le N\le 5\times 10^4, 1L,Ci1071\le L, C_i\le 10^7.