According to an old legeng, a long time ago Ankh-Morpork residents did something wrong to miss Fortune, and she cursed them. She said that at some time n snacks of distinct sizes will fall on the city, and the residents should build a Snacktower of them by placing snacks one on another. Of course, big snacks should be at the bottom of the tower, while small snacks should be at the top.

Years passed, and once different snacks started to fall onto the city, and the residents began to build the Snacktower.

<image>

However, they faced some troubles. Each day exactly one snack fell onto the city, but their order was strange. So, at some days the residents weren't able to put the new stack on the top of the Snacktower: they had to wait until all the bigger snacks fell. Of course, in order to not to anger miss Fortune again, the residents placed each snack on the top of the tower immediately as they could do it.

Write a program that models the behavior of Ankh-Morpork residents.

Input

The first line contains single integer n (1 ≤ n ≤ 100 000) — the total number of snacks.

The second line contains n integers, the i-th of them equals the size of the snack which fell on the i-th day. Sizes are distinct integers from 1 to n. 

Output

Print n lines. On the i-th of them print the sizes of the snacks which the residents placed on the top of the Snacktower on the i-th day in the order they will do that. If no snack is placed on some day, leave the corresponding line empty.

Examples

Input

3
3 1 2


Output

3
 
2 1

Input

5
4 5 1 2 3


Output

 
5 4
 
 
3 2 1

Note

In the example a snack of size 3 fell on the first day, and the residents immediately placed it. On the second day a snack of size 1 fell, and the residents weren't able to place it because they were missing the snack of size 2. On the third day a snack of size 2 fell, and the residents immediately placed it. Right after that they placed the snack of size 1 which had fallen before.
import java.util.*;
import java.io.*;
import java.math.*;
public class HackerEarth{
	static long mod=(long)Math.pow(10,9)+7;
	static final int lint=Integer.MAX_VALUE;
	static final double ldouble=Double.MAX_VALUE;
	public static void main(String args[]) {
        new Thread(null, new Runnable() {
            public void run() {
                try{
                    solve();
                }
                catch(Exception e){
                    e.printStackTrace();
                }
            }
        }, "1", 1 << 26).start();
	}
	public static void solve(){
		InputReader in = new InputReader(System.in);
        PrintWriter w = new PrintWriter(System.out);
        int n=in.nextInt();
        TreeSet<Integer> ts=new TreeSet<Integer>();
        int max=n;
        for(int i=0;i<n;i++){
        	int num=in.nextInt();
        	ts.add(num);
        	if(ts.last()==max){
        		while(ts.size()!=0&&ts.last()==max){
        			w.print(ts.pollLast()+" ");
        			max--;
        		}
        	}
        	w.println();
        }
        w.close();
	}
//	static int jackbfs(boolean arr[][],int n){
//		int count=0;
//		boolean check[][]=new boolean[n][3];
//		LinkedList<Integer> queue=new LinkedList<Integer>();
//		LinkedList<Integer> c=new LinkedList<Integer>();
//		queue.add(0);
//		queue.add(1);
//		check[0][1]=true;
//		c.add(1);
//		while(!queue.isEmpty()){
//			int a=queue.pollFirst();
//			int b=queue.pollFirst();
//			int num=c.pollFirst();
//			if(num>count){
//				count=num;
//			}
//			if(a+1<n&&!check[a+1][b]&&!arr[a+1][b]){
//				queue.add(a+1);
//				queue.add(b);
//				check[a+1][b]=true;
//				c.add(num+1);
//			}
//			if(a+1<n&&b-1>=0&&!check[a+1][b-1]&&!arr[a+1][b-1]){
//				queue.add(a+1);
//				queue.add(b-1);
//				check[a+1][b-1]=true;
//				c.add(num+1);
//			}
//			if(a+1<n&&b+1<=2&&!check[a+1][b+1]&&!arr[a+1][b+1]){
//				queue.add(a+1);
//				queue.add(b+1);
//				check[a+1][b+1]=true;
//				c.add(num+1);
//			}
//		}
//		return count;
//	}
//	static boolean isPrime[];
//	 //for marking all prime numbers greater than 1 and less than equal to N
//	static void sieve(int N) {
//        isPrime=new boolean[N+1];
//        isPrime[0] = true;
//        isPrime[1] = true;
//        for(int i = 2; i * i <= N; ++i) {
//             if(isPrime[i] == false) {                    //Mark all the multiples of i as composite numbers
//                 for(int j = i * i; j <= N ;j += i)
//                     isPrime[j] = true;
//            }
//        }
//    }
	static ArrayList<Integer> adj[]; //Adjacency Lists
    static int V;   // No. of vertices
    // Constructor
    static void Graph(int v){
        V = v;
        adj = new ArrayList[v];
        for (int i=0; i<v; ++i){
        	adj[i] = new ArrayList();
        }
    }
    // Function to add an edge into the graph
    static void addEdge(int v,int w){
    	if(!adj[v].contains(w)){
    		adj[v].add(w);
    		adj[w].add(v);
    	}
    }
    static int dfs(int s,boolean visited[]){
    	int count=0;
    	Stack<Integer> st=new Stack<Integer>();
    	st.push(s);
    	visited[s]=true;
    	while(!st.isEmpty()){
    		int num=st.pop();
    		count++;
    		for(int i=0;i<adj[num].size();i++){
    			if(!visited[adj[num].get(i)]){
    				visited[adj[num].get(i)]=true;
    				st.push(adj[num].get(i));		
    			}
    		}
    	}
    	return count;
    }
//	static boolean T[][][];
//	static void subsetSum(int input[], int total, int count) {
//        T = new boolean[input.length + 1][total + 1][count+1];
//        for (int i = 0; i <= input.length; i++) {
//        	T[i][0][0] = true;
//        	for(int j = 1; j<=count; j++){
//        		T[i][0][j] = false;
//        	}
//        }
//        int sum[]=new int[input.length+1];
//        for(int i=1;i<=input.length;i++){
//            sum[i]=sum[i-1]+input[i-1];
//        }
//        for (int i = 1; i <= input.length; i++) {
//            for (int j = 1; j <= (int)Math.min(total,sum[i]); j++) {
//            	for (int k = 1; k <= (int)Math.min(i,count); k++){
//            		 if (j >= input[i - 1]) {//Exclude and Include
//                         T[i][j][k] = T[i - 1][j][k] || T[i - 1][j - input[i - 1]][k-1];
//                     } else {
//                         T[i][j][k] = T[i-1][j][k];
//                     }
//            	}
//            }
//        }
//    }
//	static <K,V extends Comparable<? super V>>
//	SortedSet<Map.Entry<K,V>> entriesSortedByValues(Map<K,V> map) {
//	    SortedSet<Map.Entry<K,V>> sortedEntries = new TreeSet<Map.Entry<K,V>>(
//	        new Comparator<Map.Entry<K,V>>() {
//	            @Override public int compare(Map.Entry<K,V> e1, Map.Entry<K,V> e2) {
//	                int res = e2.getValue().compareTo(e1.getValue());
//	                return res != 0 ? res : 1;
//	            }
//	        }
//	    );
//	    sortedEntries.addAll(map.entrySet());
//	    return sortedEntries;
//	}
	
 
	 
	//minimum prime factor of all the numbers less than n
//	static void minimumPrime(int n){
//		int minPrime[]=new int[n+1];
//        for (int i = 2; i * i <= n; ++i) {
//            if (minPrime[i] == 0) {         //If i is prime
//                for (int j = i * i; j <= n; j += i) {
//                    if (minPrime[j] == 0) {
//                        minPrime[j] = i;
//                    }
//                }
//            }
//        }
//        for (int i = 2; i <= n; ++i) {
//            if (minPrime[i] == 0) {
//                minPrime[i] = i;
//            }
//        }
//	}
	static long power(long base, long exponent, long modulus){
	    long result = 1;
	    while (exponent > 0) {
	        if (exponent % 2 == 1)
	            result = (result * base) % modulus;
	        exponent = exponent >> 1;
	        base = (base * base) % modulus;
	    }
	    return result;
	}
	static long modInverse(long A, long M)
	{
		long x=extendedEuclid(A,M)[0];
		return (x%M+M)%M;    //x may be negative
	}
	static long[] extendedEuclid(long A, long B) {
		if(B == 0) {
			long d = A;
			long x = 1;
			long y = 0;
			return new long[]{x,y,d};
		}
		else {
			long arr[]=extendedEuclid(B, A%B);
			long temp = arr[0];
			arr[0] = arr[1];
			arr[1] = temp - (A/B)*arr[1];
			return arr;
		}
	}
//	static boolean isPrime(int n) {
//        if(n < 2) return false;
//        if(n == 2 || n == 3) return true;
//        if(n%2 == 0 || n%3 == 0) return false;	
//        int sqrtN = (int)Math.sqrt(n)+1;
//        for(int i = 6; i <= sqrtN; i += 6) {
//            if(n%(i-1) == 0 || n%(i+1) == 0) return false;
//        }
//        return true;
//    }
//	static long modpowIter(long a, long b) {
//        long ans=1;
//        while(b != 0) {
//                if(b%2==1)
//                	ans=(ans*a)%mod;
//                a=(a*a)%mod;
//                b=b>>1;
//        }
//        return ans;
//	}
	static class InputReader {
        private final InputStream stream;
        private final byte[] buf = new byte[8192];
        private int curChar, numChars;
        private SpaceCharFilter filter;
 
        public InputReader(InputStream stream) {
            this.stream = stream;
        }
        
        public int read() {
            if (numChars == -1) {
                throw new InputMismatchException();
            }
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }
 
        public String nextLine() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            StringBuilder res = new StringBuilder();
            do {
                res.appendCodePoint(c);
                c = read();
            } while (!isEndOfLine(c));
            return res.toString();
        }
 
        public String readString() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            StringBuilder res = new StringBuilder();
            do {
                res.appendCodePoint(c);
                c = read();
            } while (!isSpaceChar(c));
            return res.toString();
        }
 
        public long nextLong() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            long res = 0;
            do {
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }
 
        public int nextInt() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }
 
        public int[] nextIntArray(int n) {
            int[] arr = new int[n];
            for (int i = 0; i < n; i++) {
                arr[i] = nextInt();
            }
            return arr;
        }
 
        public long[] nextLongArray(int n) {
            long[] arr = new long[n];
            for (int i = 0; i < n; i++) {
                arr[i] = nextLong();
            }
            return arr;
        }
 
        public boolean isSpaceChar(int c) {
            if (filter != null)
                return filter.isSpaceChar(c);
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }
 
        private boolean isEndOfLine(int c) {
            return c == '\n' || c == '\r' || c == -1;
        }
        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);
        }
	}
} 
class Node{
	ArrayList<Integer> arr=new ArrayList<Integer>();
	public void set(){
		
	}
}