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())
a = list(map(int, input().split()))

# 一番左はいつも見えている
ans = (10**9)*15
for i in range(2**(n-1)):
    pattern = []
    for j in range(n-1):
        if (i >> j) & 1:
            pattern.append(j+1)
    if len(pattern) != (k-1): continue
    count = 0
    prev = a[0]
    for l in range(1, n):
        if l not in pattern:
            prev = max(prev, a[l])
            continue
        if a[l] <= prev:
            extended = prev + 1
            count += (extended - a[l])
            prev = extended
        else:
            prev = a[l]
    #print(count)
    ans = min(ans, count)
print(0 if k == 1 else ans)
