#include <bits/stdc++.h>
using namespace std;
typedef long long   signed int LL;
typedef long long unsigned int LU;
#define incII(i, l, r) for(int i = (l)    ; i <= (r); ++i)
#define incID(i, l, r) for(int i = (l)    ; i <  (r); ++i)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); --i)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec(i, n)  decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
template<typename T> bool setmin  (T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmax  (T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
LL mo(LL a, LL b) { assert(b > 0); a %= b; if(a < 0) { a += b; } return a; }
LL fl(LL a, LL b) { assert(b > 0); return (a > 0 ? a / b : (a - b + 1) / b); }
LL ce(LL a, LL b) { assert(b > 0); return (a < 0 ? a / b : (a + b - 1) / b); }
#define bit(b, i) (((b) >> (i)) & 1)
#define BC __builtin_popcountll
#define SC(T, v) static_cast<T>(v)
#define SI(v) SC(int, v.size())
#define SL(v) SC( LL, v.size())
#define RF(e, v) for(auto & e: v)
#define ei else if
#define UR assert(false)

// ---- ----

template<typename T> vector<pair<LL, T>> cc(vector<T> v) {
	vector<pair<LL, T>> a;
	inc(i, v.size()) {
		if(i == 0 || v[i] != v[i - 1]) { a.EB(1, v[i]); } else { a.back().FI++; }
	}
	return a;
}

vector<int> kougo(vector<int> & v) {
	vector<int> w;
	inc(i, SI(v)) { w.PB(v[fl(i, 2) + (i % 2) * ce(SI(v), 2)]); }
	return w;
}

#define FD(v, x) distance(v.begin(), find(ALL(v), x))

int n, k, a[50];
vector<int> b[51];

int main() {
	cin >> n >> k;
	inc(i, n) { cin >> a[i]; }
	
	vector<int> v;
	int s = 0;
	inc(i, n) {
		int c = k + 1 - a[i];
		setmax(s, c);
		inc(j, c) { v.PB(i); }
	}
	
	if(SI(v) > k || s > ce(k, 2)) {
		cout << -1 << endl;
	} else {
		inc(i, n) {
			while(SI(v) < k && count(ALL(v), i) < ce(k, 2)) { v.PB(i); }
		}
		assert(SI(v) == k);
		inc(i, n) { assert(count(ALL(v), i) <= ce(k, 2)); }
		
		sort(ALL(v));
		auto C = cc(v);
		sort(RALL(C));
		vector<int> X;
		inc(i, SI(C)) {
		inc(j, C[i].FI) {
			X.PB(C[i].SE);
		}
		}
		
		auto w = kougo(X);
		
		inc(i, k + 1) {
		inc(j, n) {
			b[i].PB(j);
		}
		}
		
		inc(i, k) {
			swap(b[i + 0][ FD(b[i + 0], w[i]) ], b[i + 0][n - 1]);
			swap(b[i + 1][ FD(b[i + 1], w[i]) ], b[i + 1][    0]);
			
			assert(b[i][n - 1] == b[i + 1][0]);
		}
		
		inc(i, k + 1) {
		inc(j, n) {
			assert(count(ALL(b[i]), j) == 1);
		}
		}
		
		vector<int> ans;
		inc(i, k + 1) {
		inc(j, n) {
			if(i > 0 && j == 0) { continue; }
			ans.PB(b[i][j]);
		}
		}
		
		inc(i, n) { assert(count(ALL(ans), i) <= a[i]); }
		
		cout << SI(ans) << endl;
		inc(i, SI(ans)) { cout << (i == 0 ? "" : " ") << ans[i] + 1; }
		cout << endl;
	}
	
	return 0;
}


Measured memory_bytes: 256