#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;
}
// author : ytczy666 
// 21.6.29 10:09
#include <bits/stdc++.h>

const int N = 110;

#define inf 0x3f3f3f3f
int n, a[N], b[N * N][N];

char str[N];

int main() {
	scanf("%d", &n);
	scanf("%s", str + 1);
	for (int i = 0; i <= n; i ++) scanf("%d", &a[i]);
	int k = inf;
	for (int i = 1; i <= n; i ++) k = std::min(k, abs(a[i] - a[i - 1]));
	printf("%d\n", k);
	for (int j = 0; j <= n; j ++) {
		int d = a[j] / k, m = a[j] % k;
		for (int i = 1; i <= k; i ++) {
			if (i <= m) b[i][j] = d + 1;
			else b[i][j] = d;
		}
	}	
	for (int i = 1; i <= k; i ++, puts(""))
		for (int j = 0; j <= n; j ++)
			printf("%d ", b[i][j]);
	return 0;
}

// 考虑最优答案最多是k=min{d_i}，再想是否一定可以构造出这样一组方案。
// 我们直接就考虑平均分配，为什么这么想，因为我们要让各部分都满足整体的关系。
// 而因为k=min{d_i},所以一定不会出现相邻两个数相等的情况，否则就把前几个数+1 