#AGC004B. [AGC004B] Colorful Slimes

[AGC004B] Colorful Slimes

Score : 400400 points

Problem Statement

Snuke lives in another world, where slimes are real creatures and kept by some people. Slimes come in NN colors. Those colors are conveniently numbered 11 through NN. Snuke currently has no slime. His objective is to have slimes of all the colors together.

Snuke can perform the following two actions:

  • Select a color ii (1iN1 \leq i \leq N), such that he does not currently have a slime in color ii, and catch a slime in color ii. This action takes him aia_i seconds.
  • Cast a spell, which changes the color of all the slimes that he currently has. The color of a slime in color ii (1iN11 \leq i \leq N-1) will become color i+1i+1, and the color of a slime in color NN will become color 11. This action takes him xx seconds.

Find the minimum time that Snuke needs to have slimes in all NN colors.

Constraints

  • 2N2,0002 \leq N \leq 2,000
  • aia_i are integers.
  • 1ai1091 \leq a_i \leq 10^9
  • xx is an integer.
  • 1x1091 \leq x \leq 10^9

Input

The input is given from Standard Input in the following format:

NN xx

a1a_1 a2a_2 ...... aNa_N

Output

Find the minimum time that Snuke needs to have slimes in all NN colors.

2 10
1 100
12

Snuke can act as follows:

  • Catch a slime in color 11. This takes 11 second.
  • Cast the spell. The color of the slime changes: 1122. This takes 1010 seconds.
  • Catch a slime in color 11. This takes 11 second.
3 10
100 1 100
23

Snuke can act as follows:

  • Catch a slime in color 22. This takes 11 second.
  • Cast the spell. The color of the slime changes: 2233. This takes 1010 seconds.
  • Catch a slime in color 22. This takes 11 second.
  • Cast the soell. The color of each slime changes: 3311, 2233. This takes 1010 seconds.
  • Catch a slime in color 22. This takes 11 second.
4 10
1 2 3 4
10

Snuke can act as follows:

  • Catch a slime in color 11. This takes 11 second.
  • Catch a slime in color 22. This takes 22 seconds.
  • Catch a slime in color 33. This takes 33 seconds.
  • Catch a slime in color 44. This takes 44 seconds.