#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 an 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

NN \le Score Percentage
11 1010
22 2020
55 3030
1010 4040
10310^3 5050
10410^4 7575
10510^5 100100

It is not guaranteed that the test case numbers are in ascending order of the data range.

For 100%100\% of the data: 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.