#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<typename A, typename B = A> using pr = pair<A, B>;
#define vec vector
#define ar array
#define len(a) ((int)((a).size()))
#define all(a) (a).begin(), (a).end()

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

    vec<int> primes;
    for (int i = 2; i <= 50; i++) {
        bool prime = true;
        for (int j = 2; j < i; j++)
            if (i % j == 0)
                prime = false;
        if (prime)
            primes.push_back(i);
    }

    int n;
    cin >> n;
    vec<int> a(n);
    for (auto &x : a)
        cin >> x;

    ll ans = 1e18;
    for (int mask = 0; mask < (1 << len(primes)); mask++) {
        vec<char> good(51);
        ll prod = 1;
        for (int i = 0; i < len(primes); i++)
            if ((mask >> i) % 2) {
                prod *= primes[i];
                for (int j = primes[i]; j <= 50; j += primes[i])
                    good[j] = 1;
            }

        bool ok = true;
        for (auto x : a)
            ok &= good[x];
        if (ok)
            ans = min(ans, prod);
    }
    cout << ans << '\n';
}

//#pragma optimization_level 3
//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordset;
*/
#define fr first
#define sc second
#define vec vector
#define pb push_back
#define pii pair<int, int>
#define forn(x,y) for(int x = 1 ; x <= (int)y ; ++x)
#define all(x) (x).begin(),(x).end()
#define fast cin.tie(0);cout.tie(0);cin.sync_with_stdio(0);cout.sync_with_stdio(0);
 
using namespace std;
 
typedef long long ll;
typedef unsigned int uint;
typedef pair<ll,ll> pll;
typedef complex<int> point;
const int nmax = 300005;
const ll linf = 1e18;
const ll mod = 998244353;
const int inf = 1e9;
const int sq = 5000;

int n;
char s[nmax];
int a[nmax];
int b[nmax];
int main(){
	cin >> n;
	for(int i = 1; i <= n; i++){
		cin >> s[i];
	}
	for(int i = 0; i <= n; i++){
		cin >> a[i];
	}
	int k = inf;
	for(int i = 0; i < n; i++){
		k = min(k,abs(a[i+1]-a[i]));
	}
	cout << k << '\n';
	for(int i = 0 ; i < k; i++){
		for(int j = 0; j <= n; j++){
			cout << (a[j]/k) + (a[j]%k > i) << ' ';
		}
		cout << '\n';
	}


	// a[i] - a[j] >= k*(dist(i,j))
}