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;

// macro
#define rep(i,n) for(i=0;i<n;i++)
#define ll long long
#define all(v) v.begin(), v.end()

// code starts
int main()
{
  int n,k;cin>>n>>k;
  vector<int> a(n);
  int i,j;
  ll ans=20000000000;
  rep(i,n)cin>>a[i];
  rep(i,1<<n)
  {
    ll cost=0;
    int colors=0;
    rep(j,n)
    {
      if(1<<j&i)colors++;
    }
    if(colors<k)continue;
    int maxh=0;
    rep(j,n)
    {
      if((1<<j&i)&&maxh>=a[j])
      {
        cost+=maxh+1-a[j];
        maxh++;
      }
      else
      {
        maxh=max(maxh,a[j]);
      }
    }
    ans=min(ans,cost);
  }
  cout<<ans<<endl;
}

