#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define dbg(...) 47
#endif
#define int long long
signed main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n, k;
cin >> n >> k;
vector<int> a(n);
for (int i = 0; i < n; i++) {
cin >> a[i];
}
int d = 1;
set<int> s(a.begin(), a.end());
if (s.size() == 1) {
for (int i = 2; i <= 1e6; i++) {
if (a[0] % i == 0 && a[0] / i * n % k == 0) {
d = i;
}
}
for (int i = 0; i < n; i++) {
a[i] /= d;
}
}
int sum = accumulate(a.begin(), a.end(), 0LL);
priority_queue<array<int, 2>> q;
for (int i = 0; i < n; i++) {
q.push({a[i], i});
}
vector<vector<int>> ans;
while (!q.empty()) {
vector<array<int, 2>> tmp;
vector<int> r;
for (int t = 0; t < k; t++) {
if (q.empty()) {
cout << -1 << '\n';
return 0;
}
auto [x, j] = q.top();
q.pop();
r.push_back(j + 1);
if (--a[j] > 0) {
tmp.push_back({a[j], j});
}
}
for (auto e : tmp) {
q.push(e);
}
ans.push_back(r);
}
cout << ans.size() << '\n';
for (auto v : ans) {
cout << d;
for (int i : v) {
cout << ' ' << i;
}
cout << '\n';
}
return 0;
}