atcoder#AGC027B. [AGC027B] Garbage Collector

[AGC027B] Garbage Collector

Score : 700700 points

Problem Statement

Snuke has decided to use a robot to clean his room.

There are NN pieces of trash on a number line. The ii-th piece from the left is at position xix_i. We would like to put all of them in a trash bin at position 00.

For the positions of the pieces of trash, 0<x1<x2<...<xN1090 < x_1 < x_2 < ... < x_{N} \leq 10^{9} holds.

The robot is initially at position 00. It can freely move left and right along the number line, pick up a piece of trash when it comes to the position of that piece, carry any number of pieces of trash and put them in the trash bin when it comes to position 00. It is not allowed to put pieces of trash anywhere except in the trash bin.

The robot consumes XX points of energy when the robot picks up a piece of trash, or put pieces of trash in the trash bin. (Putting any number of pieces of trash in the trash bin consumes XX points of energy.) Also, the robot consumes (k+1)2(k+1)^{2} points of energy to travel by a distance of 11 when the robot is carrying kk pieces of trash.

Find the minimum amount of energy required to put all the NN pieces of trash in the trash bin.

Constraints

  • 1N2×1051 \leq N \leq 2 \times 10^{5}
  • 0<x1<...<xN1090 < x_1 < ... < x_N \leq 10^9
  • 1X1091 \leq X \leq 10^9
  • All values in input are integers.

Partial Scores

  • 400400 points will be awarded for passing the test set satisfying N2000N \leq 2000.

Input

Input is given from Standard Input in the following format:

NN XX

x1x_1 x2x_2 ...... xNx_{N}

Output

Print the answer.

2 100
1 10
355
  • Travel to position 1010 by consuming 1010 points of energy.
  • Pick up the piece of trash by consuming 100100 points of energy.
  • Travel to position 11 by consuming 3636 points of energy.
  • Pick up the piece of trash by consuming 100100 points of energy.
  • Travel to position 00 by consuming 99 points of energy.
  • Put the two pieces of trash in the trash bin by consuming 100100 points of energy.

This strategy consumes a total of 10+100+36+100+9+100=35510+100+36+100+9+100=355 points of energy.

5 1
1 999999997 999999998 999999999 1000000000
19999999983
10 8851025
38 87 668 3175 22601 65499 90236 790604 4290609 4894746
150710136
16 10
1 7 12 27 52 75 731 13856 395504 534840 1276551 2356789 9384806 19108104 82684732 535447408
3256017715