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<cstdio>
#include<vector>
#include<algorithm>
#include<functional>
//#define scanf scanf_s
#define fir first
#define sec second
#define mp make_pair
#define mt make_tuple
#define pub push_back
using namespace std;
typedef long long int llint;
const llint one = 1;
const llint big = (one<<30);
const llint mod=1000000007;
int main(void){
	llint N,K,i,j,a,b,ans=big*15,gen,jam;
	vector<llint> taka;
	scanf("%lld %lld ",&N,&K);
	for(i=0;i<N;i++){
		scanf("%lld",&a);
		taka.pub(a);
	}
	for(i=0;i<(1<<N);i++){
		gen=0;jam=0;
		for(j=0;j<N;j++){
			if((i&(1<<j))!=0){gen++;}
		}
		if(gen!=K){continue;}
		gen=0;
		for(j=0;j<N;j++){
			if((i&(1<<j))==0){jam=max(jam,taka[j]);continue;}
			jam=max(jam+1,taka[j]);
			gen+=jam-taka[j];
		}
		ans=min(ans,gen);
	}
	printf("%lld\n",ans);
	return 0;

}
