Card merge game

Each merge replaces two chosen cards with their sum; after exactly m merges, minimize the total sum of all cards.

Medium5GreedyHeapSimulationImplementationInterviewNo attempts yetTime limit1sMemory limit512 MB

Problem

You have nn cards with natural numbers. Card ii shows aia_i at the start. One merge follows these steps.

  1. Choose two different cards, card xx and card yy, and compute the sum of the two numbers. (xyx \ne y)
  2. Write the computed value on both card xx and card yy.

After mm merges, the score is the sum of the numbers on all nn cards. Choose the cards to merge so the score is as small as possible, and compute the smallest possible score.

Input

The first line contains the number of cards nn (2n10002 \le n \le 1000) and the number of merges mm (0m15n0 \le m \le 15n), separated by a space.

The second line contains the nn initial natural numbers a1,a2,,ana_1, a_2, \dots, a_n, separated by spaces. (1ai10000001 \le a_i \le 1000000)

Output

Print the smallest possible score on the first line.