P11130 [AOJ] Optimal Tournament
普及
题目描述

Example

Input

4 3
1 3 4 7

Output

6

输入格式

见题面

输出格式

见题面

样例输入
4 3 1 3 4 7
样例输出
6