#d11307. 变量

变量

Variables

Problem Description

You are given nn integer constants c1,c2,…,cnc_1, c_2, \dots, c_n and an integer kk. You must assign integer values to 2k2k variables x1,x2,…,xk,y1,y2,…,ykx_1, x_2, \dots, x_k, y_1, y_2, \dots, y_k such that:

  1. For all 1≤i≤k1 \le i \le k, we have xi≤yix_i \le y_i.
  2. For all 1≤i≤n1 \le i \le n, there exists at least one jj (1≤j≤k1 \le j \le k) such that xj≤ci≤yjx_j \le c_i \le y_j.

Find the minimum possible value of $S = (y_1 + y_2 + \dots + y_k) - (x_1 + x_2 + \dots + x_k)$.

Input Format

The first line contains two integers nn and kk.

The next line contains nn integers c1,c2,…,cnc_1, c_2, \dots, c_n.

Output Format

One integer: the minimum value of SS.

Sample Input

5 2
-5 0 10 4 0

Sample Output

9

Constraints

There are 10 test points in total.

Test points 1, 2: n≤5n \le 5, −5≤ci≤5-5 \le c_i \le 5.

Test points 3, 4, 5: n≤100n \le 100.

For all data, 1≤n,k≤1051 \le n, k \le 10^5 and −109≤ci≤109-10^9 \le c_i \le 10^9.

Hint

See the attached files.