#P60. [KBC005D] Article

[KBC005D] Article

Source

This problem is adapted from Long Long OJ. All rights reserved.

Problem Description

Zero likes to print articles using an old-fashioned printer.

One day, he wants to print an article with NN characters, where the size of the ii-th character is CiC_i.

The cost of printing the article is calculated as follows:

  • Printing each line incurs a paper cost of MM units, where MM is a constant.
  • The ink cost for each line is the square of the sum of the sizes of all characters in that line.

Now, Zero wants to find the minimum cost required to print the article.

Input Format

This problem contains multiple test cases.

For each test case:

  • The first line contains two positive integers N,MN, M.
  • The next NN lines each contain a positive integer CiC_i.

The input ends with EOF.

Output Format

For each test case, output a single line with a positive integer representing the minimum cost of printing the article.

Samples

5 5
5
9
5
7
5
4 3
1
1
1
1
230
14

Data Range

Test Case ID NN \le
1,21, 2 11
3,43, 4 22
5,65, 6 55
7,87, 8 1010
9,109, 10 10310^3
111511 \sim 15 10410^4
162016 \sim 20 10510^5

For 100%100\% of the test cases, 1N1051 \le N \le 10^5, 1M10001 \le M \le 1000, 1Ci10001 \le C_i \le 1000.

It is guaranteed that the total number of input numbers does not exceed 10510^5.