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
#include<bits/stdc++.h>
#define int long long
const int inf=8938103643641919514ll;
const int mod=1000000007ll;
const int dd[]={0,-1,0,1,0};
using namespace std;
int a,b,c,d;
int p[15],q[15];
signed main(){
	int i,j,k;
	cin>>a>>b;
	for(i=0;i<a;i++)
		cin>>q[i];
	int ans=inf;
	for(i=0;i<(1ll<<a);i++){
		copy(q,q+15,p);
		if(__builtin_popcount(i)<b)
			continue;
		int u=0,v=0;
		for(j=0;j<a;j++){
			if(i&(1ll<<j)){
				if(u>=p[j]){
					v+=u+1-p[j];
					p[j]=u+1;
				}
			}
			if(u<p[j])
				u=p[j];
		}
		if(ans>v)
			ans=v;
	}
	cout<<ans<<endl;
}