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>
//WHEN IN DOUBT , USE BRUTE FORCE !!!!!!!!!
import java.lang.String;
import java.io.*;
import java.util.*;
import java.util.StringTokenizer;
//class Main    //AtCoder
//class Solution // Codechef
public class Solution2 //Codeforces
{
    static int cnt=0;
    public static void main(String args[])
    {
        try {
            FastReader sc = new FastReader();
            int TT = 1;//sc.nextInt();
            for(int hehe=1 ; hehe  <= TT ; hehe++) {
                int N=sc.nextInt();
                int arr[]=new int[N];
                for(int i=0;i<N;i++)
                    arr[i]=sc.nextInt();
                //Arrays.sort(arr);
                int board[][]=new int[N][N];
                boolean isVisited[][] = new boolean[N][N];
                for(int i=0;i<N;i++){
                    cnt=arr[i];
                    if(cnt > 0) {
                        //sopln(cnt+ "JEJEJEJE  "+arr[i]);
                        dfs(board, isVisited, i+0 , i, arr[i], N);
                    }
                }
                for(int i=0;i<N;i++){
                    for(int j=0;j<N;j++){
                        if(i>=j){
                            sop(board[i][j]+" ");
                        }
                    }
                    sopln("");
                }
                out.flush();
            }
        }catch (Exception e) {
            sopln(e.toString());
        }
    }
    public static void dfs(int board[][] , boolean isVisited[][] , int x , int y , int N , int s){
        isVisited[x][y] = true;
        board[x][y] = N;
        cnt--;
        int dx[]={0,1};
        int dy[]={-1,0};
        for(int i=0;i<=1;i++){
            int X=x+dx[i],Y=y+dy[i];
            //sopln("HJ");
            if(X>=0 && Y>=0 && X<s && Y<s && !isVisited[X][Y] && X>Y && cnt > 0)
            {
                dfs(board,isVisited,X,Y,N,s);
            }
        }
    }
    private static long sumOfDigits(long k) {
        if(k < 10) return k;
        return (k%10)+sumOfDigits(k/10);
    }

    private static boolean checkIsSorted(int[] arr) {
        int ar[]=arr;
        Arrays.sort(ar);
        return Arrays.equals(ar,arr);
    }

    static boolean isPrime(long n)
    {

        // Check if number is less than
        // equal to 1
        if (n <= 1)
            return false;

            // Check if number is 2
        else if (n == 2)
            return true;

            // Check if n is a multiple of 2
        else if (n % 2 == 0)
            return false;

        // If not, then just check the odds
        for (int i = 3; i <= Math.sqrt(n); i += 2)
        {
            if (n % i == 0)
                return false;
        }
        return true;
    }

    static long gcd(long a, long b)
    {
        if (b == 0)
            return a;
        return gcd(b, a % b);
    }

    static long countDig(long N){
        if(N < 10)
            return 1;
        else
            return 1+countDig(N/10);
    }

    private static boolean check(long[] arr) {
        for(int i=0;i<arr.length;i++){
            if(arr[i]!=0)
                return false;
        }
        return true;
    }

    public final static int d = 256;
    static int MOD = 1000000007;
    static final double PI = Math.PI;
    private static BufferedReader in = new BufferedReader (new InputStreamReader (System.in));
    private static PrintWriter out = new PrintWriter (new OutputStreamWriter (System.out));
    static class FastReader{
        BufferedReader br;
        StringTokenizer st;
        public FastReader()
        {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next()
        {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException  e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt()
        {
            return Integer.parseInt(next());
        }

        long nextLong()
        {
            return Long.parseLong(next());
        }

        char nextChar()
        {
            try {
                return (char) (br.read());
            }catch (IOException e){
                return '~';
            }
        }

        double nextDouble()
        {
            return Double.parseDouble(next());
        }

        String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
    static void sop(Object o){System.out.print(o);}
    static double ceil(double d){
        return Math.ceil(d);
    }
    static double floor(double d){
        return Math.floor(d);
    }
    static double round(double d){
        return Math.round(d);
    }

    static void sopln(Object o){System.out.println(o);}
    static void printArray(int[] arr){
        for(int i=0;i<arr.length;i++){
            sop(arr[i]+" ");
        }
        sopln("");
    }
    static void printArray(Long[] arr){
        for(int i=0;i<arr.length;i++){
            sop(arr[i]+" ");
        }
        sopln("");
    }
    static long power(long x, long y, long p)
    {

        // Initialize result
        long res = 1;

        // Update x if it is more than or
        // equal to p
        x = x % p;

        while (y > 0) {

            // If y is odd, multiply x
            // with result
            if (y % 2 == 1)
                res = (res * x) % p;

            // y must be even now
            y = y >> 1; // y = y/2
            x = (x * x) % p;
        }

        return res;
    }

    // Returns n^(-1) mod p
    static long modInverse(long n, int p)
    {
        return power(n, p - 2, p);
    }

    // Returns nCr % p using Fermat's
    // little theorem.

    ///

    // Function to find modular
// inverse of a under modulo p
// using Fermat's method.
// Assumption: p is prime
    static long modFact(int n,
                       int p)
    {
        if (n >= p)
            return 0;

        long result = 1;
        for (int i = 1; i <= n; i++)
            result = (result * i) % p;

        return result;
    }

}
