Input Format


N K
a_1 a_2 a_3 ... a_N


Output Format

Print the minimum cost in one line. In the end put a line break.


Constraints

* 1 ≤ K ≤ N ≤ 15
* 1 ≤ a_i ≤ 10^9



Scoring

Subtask 1 [120 points]


* N = K

Subtask 2 [90 points]


* N ≤ 5
* a_i ≤ 7

Subtask 3 [140 points]


* There are no additional constraints.

Output Format

Print the minimum cost in one line. In the end put a line break.


Constraints

* 1 ≤ K ≤ N ≤ 15
* 1 ≤ a_i ≤ 10^9



Scoring

Subtask 1 [120 points]


* N = K

Subtask 2 [90 points]


* N ≤ 5
* a_i ≤ 7

Subtask 3 [140 points]


* There are no additional constraints.

Input Format


N K
a_1 a_2 a_3 ... a_N

Example

Input

5 5
3949 3774 3598 3469 3424


Output

1541
n, k = map(int, input().split())
array = list(map(int, input().split()))
if k == 1:
  print(0)
  quit()
  
import itertools
cost = float('inf')
for cand in itertools.combinations(range(1, n), k-1):
  dp = array[:]
  curr_cost = 0
  for index in cand:
    max_val = max(dp[:index])
    if array[index] > max_val:
      continue
    curr_cost += max_val - array[index] + 1
    dp[index] = max_val + 1
  cost = min(cost, curr_cost)
  
print(cost)