// 论证: 差分a即可
// 构造: 把a_i平均分 
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ldouble;
template<class T> bool chmin(T &x, const T &y) {
  return x > y ? (x = y, true) : false;
}
template<class T> bool chmax(T &x, const T &y) {
  return x < y ? (x = y, true) : false;
}

#define maxk 10005
#define maxn 105
const int inf = 0x3f3f3f3f;

char s[maxn];
int n, k = inf, a[maxn];

int main() {
  scanf("%d", &n);
  scanf("%s", s + 1);
  for (int i = 0; i <= n; i++)
    scanf("%d", a + i);
  for (int i = 1; i <= n; i++)
    chmin(k, abs(a[i] - a[i - 1]));
  printf("%d\n", k);
  for (int i = 0; i < k; i++) {
    for (int j = 0; j <= n; j++) {
      printf("%d%c", (a[j] + i) / k, j == n ? '\n' : ' ');
    }
  }
  return 0;
}

#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>


#define inp 200005
#define check exit(0)
#define nl cout<<endl;
#define mod 1000000007 
#define ll long long int
#define trace(x) cerr<<#x<<" : "<<x<<endl;
#define jaldi ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define deb(v) for(int i=0;i<v.size();i++) {cout<<v[i]; (i==v.size()-1) ? cout<<"\n":cout<<" "; }
#define ordered_set tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update>

using namespace std;
using namespace __gnu_pbds; 

// Pick yourself up, 'cause...

 
int main()
{
    jaldi
 
    int n;
    cin>>n;

    vector<int> v(n);
    for(int i=0;i<n;i++) cin>>v[i];

    vector<ll> ans(n);
    ordered_set os;

    for(int i=0;i<n;i++)
    {
        ans[0] += v[i] - os.order_of_key(v[i]);
        os.insert(v[i]);
    }

    for(int i=1;i<n;i++)
    {
        ans[i] = ans[i-1] - v[i-1] + (n - 1 - v[i-1]);
    }

    for(ll x:ans) cout<<x<<" \n";

    return 0;
}
 

// Try till you are out of ideas