Problem: 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.

Solution (in JAVA):

Solution:
import java.util.*;
import java.io.*;
 public class Main {
    public static void main ( String args[] ){
      FastReader sc = new FastReader();
      PrintWriter out = new PrintWriter (System.out); 
      int n = sc.nextInt();
      Stack<Integer> s = new Stack<Integer> (); 
      TreeSet<Integer> a = new TreeSet<Integer>(); 
      Stack<Integer> s2 = new Stack<Integer> (); 
      
      for (int i = 0 ; i < n ; i++) {
    	  int c = sc.nextInt(); 
    	  if (!s.isEmpty()) {
    		  if (s.peek()== c+1) {
    			  s.add(c); 
    		  out.print(c+" "); 
    		  while(!a.isEmpty()&& s.peek()-1 == a.last()) {
    			  
    		  s.add(a.last()); 
    			  out.print(a.last()+" "); 
    			  a.remove(a.last()); }
    	  }
    		  else 
    			  a.add(c);
    	  }
    	  else if (c==n) {
    		  s.add(c); 
    	  out.print(c+" ");
    	  while(!a.isEmpty()&& s.peek()-1 == a.last()) {
			  
    		  s.add(a.last()); 
    			  out.print(a.last()+" "); 
    			  a.remove(a.last()); }
    	  
    	  }
    	  else 
    		  a.add(c); 
    	  
    	 //out.println(a+" "+s); 
    	  
    	  out.println(); 
    		  
    	  
      }
      out.flush();
    }
    
      
    
 
      
 
 
 
      
    
    
      static boolean check(long x ) {
    	  double y = Math.sqrt(x);
    	  int z = (int)(y);
    	  if (z==y)
    		  return true ; 
    	  else 
    		  return false ; 
      }
    
    
    static int [] freq (int [] a ) {
    	int max = 0 ; 
    	for (int i =0 ; i < a.length ; i++) {
    		max = Math.max(a[i], max); 
    		
    	}
    	int [] b = new int [max+1]; 
    	for (int i = 0 ; i < a.length ; i++) {
    		b[a[i]]++;
    		
    	}
    	return b ; 
    	
    }
     static class Graph 
    { 
        private int V;   // No. of vertices 
      
        // Array  of lists for Adjacency List Representation 
        private LinkedList<Integer> adj[]; 
      
        // Constructor 
        Graph(int v) 
        { 
            V = v; 
            adj = new LinkedList[v]; 
            for (int i=0; i<v; ++i) 
                adj[i] = new LinkedList(); 
        } 
      
        //Function to add an edge into the graph 
        void addEdge(int v, int w) 
        { 
            adj[v].add(w);  // Add w to v's list. 
        } 
      
        // A function used by DFS 
        void DFSUtil(int v,boolean visited[]) 
        { 
            // Mark the current node as visited and print it 
            visited[v] = true; 
            System.out.print(v+" "); 
      
            // Recur for all the vertices adjacent to this vertex 
            Iterator<Integer> i = adj[v].listIterator(); 
            while (i.hasNext()) 
            { 
                int n = i.next(); 
                if (!visited[n]) 
                    DFSUtil(n, visited); 
            } 
        } 
      
        // The function to do DFS traversal. It uses recursive DFSUtil() 
        void DFS(int v) 
        { 
            // Mark all the vertices as not visited(set as 
            // false by default in java) 
            boolean visited[] = new boolean[V]; 
      
            // Call the recursive helper function to print DFS traversal 
            DFSUtil(v, visited); 
        } 
    }
    public static long sum (long mid, long k ) {
    	long sum1 = (mid-1)*(mid) /2 ;
    	long sum2 = (k)*(k+1) /2 ; 
    	return sum2-sum1 ; 
    	
    	
    }
    public static void swap(Long []a ,int i , int j ) {
    	long temp = a[i]; 
    	a[i]= a[j]; 
    	a[j]= temp ; 
    	
    }
    
    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()); 
		} 
		
		double nextDouble() 
		{ 
			return Double.parseDouble(next()); 
		} 
		
		String nextLine() 
		{ 
			String str = ""; 
			try
			{ 
				str = br.readLine(); 
			} 
			catch (IOException e) 
			{ 
				e.printStackTrace(); 
			} 
			return str; 
		}
}
 }
  class Pair {
	int x ; 
	int y ; 
	public Pair(int x ,int y){
		this.x = x;
		this.y=y;}
}
 
  class Pair1 implements Comparable{
	int x ; 
	int y ; 
	public Pair1(int x ,int y){
		this.x = x;
		this.y=y;}
	public int compareTo(Object o) {
		Pair1 a = (Pair1) o ; 
		
		return (a.x-this.x);
	}
		
	}
 class Pair2 implements Comparable{
	int x ; 
	int y ; 
	public Pair2(int x ,int y){
		this.x = x;
		this.y=y;}
	public int compareTo(Object o) {
		Pair2 a = (Pair2) o ; 
		
		return (this.y-a.y);
	}
 }