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 <iostream>
#include <vector>
#include <algorithm>

#define REP(i,a,b) for(int i=int(a);i<int(b);i++)

using namespace std;

typedef long long int lli;

int main () {
    int N, K;
    cin >> N >> K;
    vector<lli> a(N);
    REP (i, 0, N) cin >> a[i];
    lli m = 1LL << 60;
    vector<int> patterns(N, 0);
    REP (i, 0, K) patterns[i] = 1;
    sort(patterns.begin(), patterns.end());
    do {
        lli cost = 0;
        lli tall = 0;
        REP (i, 0, N) {
            if (patterns[i]) {
                if (tall > a[i]) cost += (tall - a[i]);
            }
            tall = max(a[i], tall) + patterns[i];
        }
        m = min (m, cost);
    } while (next_permutation(patterns.begin(), patterns.end()));
    cout << m << endl;
    return 0;
}
