#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define each(e, v) for(auto &e: v)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(x) (int)x.size()
using ll = long long;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const int MOD = 1000000007;
//const int MOD = 998244353;
const int inf = (1<<30)-1;
const ll INF = (1LL<<60)-1;
template<typename T> bool chmax(T &x, const T &y) {return (x < y)? (x = y, true) : false;};
template<typename T> bool chmin(T &x, const T &y) {return (x > y)? (x = y, true) : false;};

struct io_setup{
    io_setup(){
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        cout << fixed << setprecision(15);
    }
} io_setup;

int N;
string S;
vector<int> L, R;

vector<int> nxt(vector<int> A){
    int K = inf;
    rep(i, N) chmin(K, abs(A[i+1]-A[i]));

    if(K == 1) return A;

    vector<int> ret(N+1);

    int m = *min_element(all(A));

    rep(i, N+1){
        ret[i] = (A[i]-m)/K;
    }

    return ret;
}

int main(){
    cin >> N >> S;
    vector<int> A(N+1);
    rep(i, N+1) cin >> A[i];

    L.assign(N+1, 0), R.assign(N+1, 0);

    rep(i, N+1){
        int tmp = 0;
        rep3(j, i-1, 0){
            if(A[j] < A[j+1]) tmp--;
            else tmp++;
            chmin(L[i], tmp);
        }

        tmp = 0;
        rep2(j, i+1, N){
            if(A[j-1] > A[j]) tmp--;
            else tmp++;
            chmin(R[i], tmp);
        }
    }

    int K = inf;
    rep(i, N) chmin(K, abs(A[i+1]-A[i]));

    cout << K << '\n';

    rep(i, K){
        vector<int> v = nxt(A);
        rep(j, N+1) cout << v[j] << (j == N? '\n' : ' ');
        rep(j, N+1) A[j] -= v[j];
    }
}
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
// #include <atcoder/all>
// using namespace atcoder;
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << "\n"

void solve(){
    ll N,K;
    cin >> N >> K;
    ll ans = 0;
    rep(ab,2,2*N+1){
        ll cd = ab - K;
        if(cd >= 2 && cd <= 2*N){
            ll n1 = 0, n2 = 0;
            if(ab <= N){
                n1 = ab-1;
            }else{
                n1 = 2 * N - ab + 1;
            }
            if(cd <= N){
                n2 = cd - 1;
            }else{
                n2 = 2 * N - cd + 1;
            }


            ans += n1 * n2;
        } 
    }
    print(ans);
    

}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
}