Universal Cup Judging System

Universal Cup

時間限制: 1 s 記憶體限制: 512 MB 總分: 100 可 Hack ✓
统计

You have a fair $n$-sided die with positive integer face values $a_1,a_2,\ldots,a_n$. You want to design another fair $m$-sided die with positive integer face values $b_1,b_2,\ldots,b_m$. Every face of a die is equally likely to be rolled. Face values may repeat on either die.

Roll each die once, independently. The new die wins if and only if its value is strictly greater than the original die’s value; a tie is not a win.

Find the minimum possible sum $b_1+b_2+\cdots+b_m$ of the new die’s face values such that it wins with probability strictly greater than $50\%$.

Input

The first line contains two integers $n,m$ ($2 \le n \le 50$, $1 \le m \le 10^9$), the numbers of faces of the original die and the new die, respectively.

The second line contains $n$ integers $a_1,a_2,\ldots,a_n$ ($1 \le a_i \le 10^9$), the face values of the original die.

Output

Print one integer: the minimum possible sum of the new die’s face values such that its probability of winning is strictly greater than $50\%$.

Examples

Input 1

6 6
1 2 3 4 5 6

Output 1

25

Input 2

3 2
1 1 2

Output 2

4

Input 3

4 4
3 7 10 11

Output 3

29

Note

In the first example, an optimal new die has face values $1,1,2,7,7,7$, whose sum is $25$. It wins $0+0+1+6+6+6=19$ of the $36$ equally likely pairs of faces.

In the second example, an optimal new die has face values $2,2$. Each face beats the two faces labeled $1$ on the original die, so the new die wins $4$ of the $6$ equally likely pairs. Its face values sum to $4$.

In the third example, an optimal new die has face values $1,4,12,12$. It wins $0+1+4+4=9$ of the $16$ equally likely pairs, and its face values sum to $29$.

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.