Problem: Fillomino is a classic logic puzzle. (You do not need to know Fillomino in order to solve this problem.) In one classroom in Yunqi town, some volunteers are playing a board game variant of it:

Consider an n by n chessboard. Its rows are numbered from 1 to n from the top to the bottom. Its columns are numbered from 1 to n from the left to the right. A cell on an intersection of x-th row and y-th column is denoted (x, y). The main diagonal of the chessboard is cells (x, x) for all 1 ≤ x ≤ n.

A permutation of \{1, 2, 3, ..., n\} is written on the main diagonal of the chessboard. There is exactly one number written on each of the cells. The problem is to partition the cells under and on the main diagonal (there are exactly 1+2+ … +n such cells) into n connected regions satisfying the following constraints:

  1. Every region should be connected. That means that we can move from any cell of a region to any other cell of the same region visiting only cells of the same region and moving from a cell to an adjacent cell. 
  2. The x-th region should contain cell on the main diagonal with number x for all 1≤ x≤ n. 
  3. The number of cells that belong to the x-th region should be equal to x for all 1≤ x≤ n. 
  4. Each cell under and on the main diagonal should belong to exactly one region. 

Input

The first line contains a single integer n (1≤ n ≤ 500) denoting the size of the chessboard.

The second line contains n integers p_1, p_2, ..., p_n. p_i is the number written on cell (i, i). It is guaranteed that each integer from \{1, …, n\} appears exactly once in p_1, ..., p_n.

Output

If no solution exists, output -1.

Otherwise, output n lines. The i-th line should contain i numbers. The j-th number on the i-th line should be x if cell (i, j) belongs to the the region with x cells.

Examples

Input


3
2 3 1


Output


2
2 3
3 3 1


Input


5
1 2 3 4 5


Output


1
2 2
3 3 3
4 4 4 4
5 5 5 5 5

Note

The solutions to the examples are illustrated in the following pictures: <image> <image>

Solution (in CPP):

Solution:
#include<iostream>
#include<vector>
#include<map>
#include<unordered_map>
#include<set>
#include<algorithm>
#include<climits>
#include<cstring>
using namespace std;
#define int            long long
#define fr1(i,a,b)     for(int i=a;i<b;i++)
#define fr2(i,b)       for(int i=b;i>=0;i--)
#define r(n)           int n; cin>>n;
#define rs(s)          string s; cin>>s;
#define rc(ch)         char ch; cin>>ch;
#define fast           ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define sa(a,n)        sort(a,a+n)
#define sv(v)          sort(v.begin(),v.end())
#define cy             cout<<"YES"
#define cn             cout<<"NO"
#define nl             cout<<"\n";
#define vi             vector<int>
#define pb             push_back
#define ia(a,n)        for(int i=0;i<n;i++) cin>>a[i];
#define oa(a,n)        for(int i=0;i<n;i++) cout<<a[i]<<" "; 
#define mod            1000000007
#define pv(v)          for(auto x: v) cout<<x<<" ";   
#define sz(v)          int((v).size())
#define rv(v)          reverse(v.begin(),v.end())
#define fr             first
#define sc             second
#define uci            unordered_map<char, int>
#define uic            unordered_map<int, char>
#define uii            unordered_map<int, int>
#define mci            map<char, int>
#define mic            map<int, char>
#define mii            map<int, int>
#define pii            pair<int, int>
#define pci            pair<char, int>
#define pic            pair<int, char>
#define max3(a,b,c)	   max(a, max(b, c))
#define max4(a,b,c,d)  max(a, max(b, max(c, d)))
#define accu(v)        accumulate(v.begin(), v.end(), 0); 
#define vcnt(v,x)      count(v.begin(), v.end(), x)
#define maxElem(v)     max_element(v.begin(), v.end())
#define mst0(arr)      memset(arr, 0, sizeof(arr));
#define mst1(arr)      memset(arr, 1, sizeof(arr));
#define mst(arr)       memset(arr, -1, sizeof(arr));

int mat[505][505];
int arr[10000000];
void solve(){
	r(n);
	ia(arr,n);
	mst0(mat);
	fr2(k, n-1){
		int i = k, j = k;
		int cnt = arr[k];
		int value = arr[k];
		while(cnt--){
			//phle check kro down ja pare ho
			mat[i][j] = value;
			//cout<<mat[i][j]<<" ";
			if(mat[i + 1][j] == 0 and i < n - 1){
				i++;
			}
			//nhi to hum left jayenge
			else {
				j--;
			}
		} 
	}
	fr1(i,0,n){
		fr1(j,0,i+1){
			cout<<mat[i][j]<<" ";
		}
		nl;
	}
}
signed main(){
	 fast;
	// r(t);
	// while(t--){
		solve();
	// }
	return 0;
}
 //      0 1 2
       
 // 0 -> 3 4 8 -> -1 -1  3
 // 1 -> 5 5 4 -> -1 -1 -1
 // 2 -> 1 2 12 -> 1  2 -1
 //bubble sort se sort krdo