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

#define _CRT_SECURE_NO_WARNINGS

#include<iostream>
#include<functional>
#include<algorithm>
#include<stack>
#include<queue>
#include<iomanip>
#include<set>
#include<map>
#include<utility>
#include<string>
#include<vector>

using namespace std;

#define LL long long
const int dx[4] = { 1,0,-1,0 };
const int dy[4] = { 0,1,0,-1 };
bool IA(int x, int y, int H, int W) { return (0<=x && x<=H) && (0<=y && y<=W); }

LL N,K,a[15],sum=(1ll<<60);

int main(){
	cin>>N>>K;
	for(int i=0;i<N;i++)cin>>a[i];

	for(int b=1;b<(1<<N);b++){
		LL tmp=0ll,hi=0ll,on=0ll;
		for(int d=0;d<15;d++)if(b&(1<<d))on++;
		if(on<K)continue;
		for(int i=0;i<N;i++){
			if(i){
				hi=max(hi,a[i-1]);
				if((b&(1<<i)) && hi>=a[i]){
					hi++;
					tmp+=hi-a[i];
				}
			}
		}
		sum=min(sum,tmp);
	}
	cout<<sum<<endl;
	return 0;
}
