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**18
for i in range(2**n):
  build=set()
  maxi=a[0]
  for j in range(n):
    if (i>>j)&1:
      build.add(j)
  cnt=len(build)
  if 0 not in build:
    cnt+=1
  s=0
  for j in range(n):
    if j==0:
      continue
    elif j in build:
      if a[j]<=maxi:
        s+=maxi-a[j]+1
        maxi+=1
      else:
        maxi=a[j]
    else:
      if a[j]>maxi:
        cnt+=1
        maxi=a[j]
  if cnt>=k:
    ans=min(ans,s)
print(ans)