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>
using namespace std;
using ll = long long;
const int MOD = 1e9+7;

ll dfs(bitset<15> b,int k,vector<int> &a,int now){
	ll ans=1e18;
	int n=a.size();
	if(now==n){
		if(b.count()!=k) return ans;
		ll sum{};
		int hi{a.at(0)};
		for(int i=1; i<n; i++){
			if(b.test(i)){
				if(a.at(i)<=hi) {
					sum+=hi-a.at(i)+1;
					hi++;
				}
			}
			hi = max(hi,a.at(i));
		}
		ans = sum;
	}
	else {
		ans=min(ans,dfs(b,k,a,now+1));
		b.set(now);
		ans=min(ans,dfs(b,k,a,now+1));
		b.reset(now);
	}
	return ans;
}
 
int main(){
	
	int n,k; cin>>n>>k;
	vector<int> a(n);
	for(auto &i:a) cin>>i;
	cout <<dfs(bitset<15>(),k,a,0)<<endl;
	
	
}