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**100
for i in range(2**(N-1)):
  bit=format(i,'0'+str(N)+'b')
  bit=list(map(int,bit))
  maxh=A[0]
  price=0
  color=1
  for n in range(N):
    if n==0:continue
    elif bit[n]==0:
      if A[n]>maxh:
        color+=1
        maxh=A[n]
    else:
      if A[n]<=maxh:
        maxh+=1
        price+=maxh-A[n]
        color+=1
      else:
        color+=1
        maxh=A[n]
  if color>=K and price<=ans:
    ans=price
print(ans)
      