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 <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <unordered_map>
#include <cstring>
#include <queue>
#include <map>
using namespace std;
typedef long long ll;
const int maxn = 15;

int n,m,a[maxn];

int main() {
  //freopen("in.cpp","r",stdin);
  cin>>n>>m;
  for(int i=0; i<n; i++)cin>>a[i];
  ll ret=-1;
  for(int i=1; i<(1<<n); i++) {
    int cnt=0;
    for(int j=0; j<n; j++)if(i&(1<<j))cnt++;
    if(cnt!=m)continue;
    ll ans=0;
    int pre=0;
    for(int j=0; j<n; j++) {
      if(i&(1<<j)) {
        if(a[j]>pre) {
          pre=a[j];
        } else {
          ans+=pre+1-a[j];
          pre++;
        }
      } else {
        if(a[j]>pre) {
          pre=a[j];
        }
      }
    }
    if(ret==-1||ret>ans)ret=ans;
  }
  cout<<ret<<endl;
  return 0;
}
