#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#define int long long
using namespace std;
inline int read()
{
	int x=0;
	bool flag=1;
	char c=getchar();
	while(c<'0'||c>'9')
	{
		if(c=='-')
			flag=0;
		c=getchar();
	}
	while(c>='0'&&c<='9')
	{
		x=(x<<1)+(x<<3)+c-'0';
		c=getchar();
	}
	return (flag?x:~(x-1));
}
int L,R,ans,p[1000001]; 
signed main()
{
	L=read();
	R=read();
	for(int i=0;i<=R;i++)
		p[i]=1;
	for(int i=2;i<=R;i++)
		for(int l=i*2;l<=R;l+=i)
			p[l]-=p[i];
	for(int i=2;i<=R;i++)
	{
		int a=R/i-(L-1)/i;
		ans+=a*a*p[i];
	}
	for(int i=max(2ll,L);i<=R;i++)
		ans+=1-2*(R/i-(L-1)/i);
	cout<<ans;
	return 0;
}

#include<bits/stdc++.h>
#define For(i,a,b) for(int i=(a),i##END=(b);i<=i##END;i++)
#define Rof(i,b,a) for(int i=(b),i##END=(a);i>=i##END;i--)
#define go(u) for(int i=head[u];i;i=nxt[i])
using namespace std;
inline int read(){
    int x=0,f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=(x<<1)+(x<<3)+(ch^48);ch=getchar();}
    return x*f;
}
const int N=1e2+10,M=1e4+10;
char s[N];int a[N],b[M][N];
signed main(){
	int n=read()+1;
	scanf("%s",s+1);
	For(i,1,n)a[i]=read();
	int k=1e5;
	For(i,2,n)k=min(k,abs(a[i]-a[i-1]));
	printf("%d\n",k);
	For(i,1,k){
		For(j,1,n){
			printf("%d ",(a[j]+i-1)/k);
		}
		puts("");
	}
	return 0;
}