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

typedef long long ll;
typedef pair<ll,ll> P;

const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;

#define rep(i, a, b) for(ll (i) = (a); (i) < (b);++i)

ll N;
ll A[2*100000];

int main()
{
  cin >> N;
  rep(i,0,N){
    cin >> A[i];
  }
  ll adv[N] = {};
  ll cnt = 0;
  rep(i,0,N){
    adv[i] = A[i];
    rep(j,1,N-i){
      adv[i+j] = adv[i+j-1] + A[i+j];
      cout << adv[i+j] << " ";
      if (adv[i+j] == 0)cnt++;
    }
    cout << endl;
    rep(j,0,N)adv[j] = 0;
  }
  cout << cnt << endl;
  return 0;
}
