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 rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
const ll INF=1e18;
const int MOD=1e9+7;
const double pi=acos(-1);

int main(){
  int n,k;
  cin >> n >> k;
  vector<ll>a(n);
  rep(i,n) cin >> a[i];
  ll ans=INF;
  
  for(int bit=0;bit<(1<<(n-1));bit++){
    vector<bool>tower(n-1);
    int cnt=0;
    rep(i,n-1){
      if(bit&(1<<i)){
        cnt++;
        tower[i]=true;
      }
      else tower[i]=false;
    }
    if(cnt<k-1)continue;
    ll sum=0;
    ll nowmax=a[0];
    rep(i,n-1){
      if(!tower[i]) nowmax=max(a[i+1],nowmax);
      else{
        sum+=max(0ll,nowmax-a[i+1]+1);
        nowmax=max(nowmax+1,a[i+1]);
      }
    }
    ans=min(ans,sum);    
  }
  cout << ans << endl;
  return 0;
}
