Splitting Game Levels

Partition n levels into k consecutive groups to minimize the expected total time of a random coin-draw process, and print it to six decimals.

Hard8Dynamic programmingDivide and conquerProbabilityPrefix sumInterviewNo attempts yetTime limit2sMemory limit512 MB

Problem

Areum plays a computer game with nn levels, numbered 11 through nn.

The nn levels are split into kk groups. Each group consists of consecutive levels, every level belongs to exactly one group, and no group is empty.

The game repeats the following process.

  1. If every level is cleared, the game ends. Otherwise the system finds the first group that still has at least one uncleared level. Call this group XX.
  2. The system prepares an empty bag for coins. One coin represents one level, and several coins may represent the same level.
    • For every already cleared level ii in group XX, the system puts tit_i coins representing level ii into the bag.
    • Let jj be the first uncleared level in group XX. The system puts tjt_j coins representing level jj into the bag.
  3. The system picks one coin from the bag uniformly at random and tells Areum the level that coin represents. Areum plays that level for one hour and always clears it. If the level was already cleared, the hour is still spent and nothing about the cleared levels changes.

The expected time until the game ends depends on how the levels are split. Given nn, kk and t1,t2,,tnt_1, t_2, \dots, t_n, write a program that computes the expected time for a split that makes it as small as possible.

Input

The first line contains nn and kk. (1n2000001 \le n \le 200\,000, 1kmin(50,n)1 \le k \le \min(50, n))

The second line contains t1,t2,,tnt_1, t_2, \dots, t_n. (1ti1000001 \le t_i \le 100\,000)

Output

Print the smallest expected time on one line, rounded to six digits after the decimal point. Pad with zeros so that six digits always follow the decimal point.

Hint

In the first example, putting level 11 in one group and the remaining levels in the other group is optimal.

In the second example, splitting the levels into two groups of three is optimal.