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 main(){
  int64_t n,k;
  cin >> n >> k;
  int64_t a[n];
  for(int64_t i=0;i<n;i++)cin >> a[i];
    int64_t ans=1000000000000000000;
  for(int64_t bit=0;bit<(1<<n);bit++){
    if(__builtin_popcount(bit)<k || bit%2==0)continue;
    vector<int64_t> s;
    for(int64_t i=0;i<n;i++){
      if(bit&(1<<i)){
          s.push_back(i);
      }
    }
    s.push_back(n);
    int64_t l=0,sum=0;
    for(int64_t j=0;j<s.size()-1;j++){
        l=max(l+1,*max_element(a+s[j],a+s[j+1]));
        sum+=l-a[s[j]];
    }
    ans=min(ans,sum);
  }
  cout << ans << endl;
}
