#include <bits/stdc++.h>
using namespace std;
 

// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>


#define pb push_back
#define pob pop_back
#define S second
#define F first
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define vll vector<long long int>
#define pll pair<long long int,long long int>
/* unordered_map<int,int>mp; mp.reserve(1024); mp.max_load_factor(0.25); */
#define mod 1000000007
#define mod2 998244353
#define ll long long int
#define ld long double
#define pi 3.141592653589793238
#define Endl endl
#define endl "\n"
const int N = 2e5 + 15;
const ll inf = 1e18;

ll n , m;
vll p(N),r(N);
ll get(ll a)
{
        if(p[a] == a)
                return a;
        p[a] = get(p[a]);
        return p[a];
}
void merge(ll a,ll b)
{
        a = get(a);
        b = get(b);
	if(a == b)
		return;
        if(r[a] >= r[b])
                p[b] = a , r[a] += r[b];
        else if(r[b] > r[a])
                p[a] = b , r[b] += r[a];
}
void init(ll n)
{
        for(ll i=0;i<=n;i++)
                p[i] = i , r[i] = 1;
}

void solve()
{
        cin >> n;
        vll a(n);
        for(auto &x:a)
                cin >> x;
        init(N-1);
        for(ll i = 0 ; i < n/2 ; i++ )
        {
                if(a[i] != a[n-1-i])
                        merge(a[i] , a[n-i-1]);
        }
        ll ans = 0;
        set<ll> pars;
        for(auto x:a)
                pars.insert(get(x));
        for(auto x:pars)
                ans += r[x] - 1;
        cout << ans;
}         

void debug(ll tt) {}
 
signed main()
{
        FAST;
        int t = 1;
        // cin >> t;
        while(t--)
        {
                solve();
        }
}
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int main()
{
	int N; cin>>N;
	string S; cin>>S;
	vector<int> a(N+1);
	for(int i=0; i<N+1; i++) cin>>a[i];
	
	int K=10000;
	for(int i=0; i<N; i++){
		K = min(K,abs(a[i]-a[i+1]));
	}

	vector<int> thre(N+1);
	for(int i=0; i<N+1; i++){
		thre[i] = a[i]-a[i]/K*K;
	}

	cout<<K<<"\n";
	for(int k=0; k<K; k++){
		for(int i=0; i<N+1; i++){
			int val = (k<thre[i])?(a[i]+K-1)/K:a[i]/K;
			cout<<val<<" \n"[i==N];
		}
	}

	return 0;
}
