#pragma GCC optimize ("O2")
#pragma GCC target ("avx2")
//#include<bits/stdc++.h>
//#include<atcoder/all>
//using namespace atcoder;
#include<iostream>
#include<cstring>

using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int MAX = 10010;
class shuturyoku_unko {
public:
	char C[MAX * 6];
	constexpr shuturyoku_unko() : C() {
		rep(i, MAX) {
			int X = i;
			rep(j, 5) {
				C[i * 6 + 4 - j] = '0' + X % 10;
				X /= 10;
			}
			C[i * 6 + 5] = ' ';
		}
	}
};
constexpr shuturyoku_unko f;

char T[800], *ci = T, c, *di;
int N, A[110], B[110];
bool furagu[10001];
inline void keisan(int s) {
	di = T;
	rep(i, N + 1) {
		int tmp = A[i] + (B[i] > s);
		int tmp2;
		if (tmp >= 1000) {
			if (tmp >= 10000) tmp2 = 6;
			else tmp2 = 5;
		}
		else {
			if (tmp >= 100) tmp2 = 4;
			else if (tmp >= 10) tmp2 = 3;
			else tmp2 = 2;
		}
		memcpy(di, f.C + tmp * 6 + 6 - tmp2, tmp2);
		di += tmp2;
	}
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);


	fread(T, 800, 1, stdin);
	while ((c = *ci++) >= '0') N = N * 10 + c - '0';
	ci += N + 1;
	rep(i, N + 1) {
		while ((c = *ci++) >= '0') A[i] = A[i] * 10 + c - '0';
	}

	int saishou = 1e9;
	rep(i, N) if (saishou > abs(A[i] - A[i + 1])) saishou = abs(A[i] - A[i + 1]);

	rep(i, N + 1) {
		B[i] = A[i] % saishou;
		A[i] = A[i] / saishou;
		furagu[B[i]] = 1;
	}

	printf("%d\n", saishou);
	keisan(0);
	rep(s, saishou) {
		if (furagu[s]) keisan(s);
		fwrite(T, 1, di - T, stdout);
	}

	Would you please return 0;
}
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
const ll INF = 1LL<<60;//1152921504606846976
const int mod = 1000000007;


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n; cin>>n;
    string s;cin>>s;
    vector<ll> a(n+1);rep(i,n+1)cin>>a[i];
    ll ans = INF;
    rep(i,n)ans = min(ans, abs(a[i+1]-a[i]));
    vector<vector<ll>> b(ans, vector<ll>(n+1,0));
    rep(i,n+1){
        ll idx = 0;
        while(a[i]){
            b[idx][i]++;
            a[i]--;
            idx++;
            idx%=ans;
        }
    }
    cout<<ans<<endl;
    rep(i,ans){
        rep(j,n+1){
            cout<<b[i][j]<<" ";

        }
        cout<<endl;
    }
    return 0;
}