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;

int n,m,a[1005]; bool bo[1005]; long long ans;
void calc(){
	int i,mx=0; long long tmp=0;
	for (i=1; i<=n; i++){
		if (bo[i] && a[i]<=mx){
			tmp+=mx+1-a[i]; mx++;
		}
		mx=max(mx,a[i]);
	}
	ans=min(ans,tmp);
}
void dfs(int k,int s){
	if (k>m){
		calc(); return;
	}
	int i;
	for (i=s+1; i<=n-m+k; i++){
		bo[i]=1;
		dfs(k+1,i);
		bo[i]=0;
	}
}
int main(){
	scanf("%d%d",&n,&m);
	int i;
	for (i=1; i<=n; i++) scanf("%d",&a[i]);
	ans=1000000000000000000ll;
	dfs(1,0);
	printf("%lld\n",ans);
	return 0;
}
