#include<bits/stdc++.h>
using namespace std;
int a[505],ch[505][505],cnt[505];
int main(){
    ios_base::sync_with_stdio(0),cin.tie(0);
    int n,c=0,i,j;
    cin>>n;
    for(i=1;i<=n;i++)cin>>a[i],ch[i][i]=a[i],cnt[a[i]]=a[i]-1;
    for(i=1;i<=n&&c==0;i++){
        int x,y;
        x=y=i;
        while(cnt[a[i]]>0){
            cnt[a[i]]--;
            if(x-1>0&&ch[y][x-1]==0)x--,ch[y][x]=a[i];
            else if(y+1<=n&&ch[y+1][x]==0)y++,ch[y][x]=a[i];
            else {c=1;break;}
        }
    }
    if(c)cout<<"-1\n";
    else{
        for(i=1;i<=n;i++){
            for(j=1;j<=i;j++)cout<<ch[i][j]<<" ";
            cout<<endl;
        }
    }
    return 0;
}
