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:

/**
 * @author kunal05
 */

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.*;

public class A{
	public static void main(String[] args) {
		InputReader in = new InputReader();
		PrintWriter out = new PrintWriter(System.out);
		final long start = System.currentTimeMillis();
		new Task1().solve(in, out);
		final long duration = System.currentTimeMillis()-start;
		out.close();
	}
	
	static class Task1 extends Utility{
		public void solve(InputReader in , PrintWriter out){
			int n = in.nextInt();
			int largest = n;
			PriorityQueue<Integer> queue = new PriorityQueue<Integer>(Collections.reverseOrder());
			for(int i=0; i<n; i++){
				int temp = in.nextInt();
				queue.add(temp);
				while(!queue.isEmpty() && largest>0 && queue.peek()==largest){
					out.print(queue.remove()+" ");
					largest--;
				}
				out.println();
			}
		}
	}
	static class InputReader {
		public BufferedReader reader;
		public StringTokenizer tokenizer;
		public InputReader() {
			reader = new BufferedReader(new InputStreamReader(System.in));
			tokenizer = null;
		}
		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
		public double nextDouble() {
			return Double.parseDouble(next());
		}
		public String nextLine() {
			String s=null;
			try{
				s = reader.readLine();
			} catch(IOException e){
				throw new RuntimeException(e);
			}
			return s;
        }
		public String nextParagraph() {
			String line=null, ans = "";
			try{
				while ((line = reader.readLine()) != null) {
				ans += line;
				}
			} catch(IOException e){
				throw new RuntimeException(e);
			}
			return ans;
		}	
	}
	static class QuickUnion{
		int[] id;
		int[] size;
		public QuickUnion(int n){
			id = new int[n];
			size = new int[n];
			for(int i=0; i<n; i++){
				id[i] = i;
				size[i] = 1;
			}
		}
		public int root(int a){
			while(a!=id[a]){
				id[a] = id[id[a]];
				a = id[a];
			}
			return a;
		}
		public boolean connected(int p, int q){
			return root(p)==root(q);
		}
		public void union(int p, int q){
			int pid = root(p);
			int qid = root(q);
			if(pid==qid) return;
			if(size[pid]>=size[qid]){
				size[pid] += size[qid];
				id[qid] = pid;
			} else {
				size[qid] += size[pid];
				id[pid] = qid;
			}
		}
	}
	static class Utility{
		static final int MOD = 1000000007;
		long expo(long a, long b){
			long result = 1;
			while (b>0){
				if (b%2==1) result=(result*a)%MOD;
				b>>=1;
				a=(a*a)%MOD;
			}
			return result%MOD;
		}
		long fibonacci(long n){
			if(n==0) return 0;
			long a=0, b=1, c=1, d=1, e=n-2;
			long a1, b1, c1, d1, a2=0, b2=1, c2=1, d2=1;
			
			while(e>0){
				if(e%2==1){
					a1 = (a*a2+b*c2)%MOD;
					c1 = (c*a2+d*c2)%MOD;
					b1 = (a*b2+ b*d2)%MOD;
					d1 = (b2*c+ d*d2)%MOD;
					a=a1; b=b1; c=c1; d= d1;
				}
				a1 = (a2*a2+b2*c2)%MOD;
				c1 = (c2*a2+d2*c2)%MOD;
				b1 = (a2*b2+ b2*d2)%MOD;
				d1 = (b2*c2+ d2*d2)%MOD;
				a2=a1; b2=b1; c2=c1; d2= d1;
				e /= 2;
			}
			return d;
		}
		long gcd(long a, long b){
			long mod = b%a;
			while(mod!=0){
				b=a;
				a=mod;
				mod=b%a;
			}
			return a;
		}
		long inverseModullo(long numerator, long denominator){
			return ((numerator%MOD)*(expo(denominator, MOD-2)))%MOD;
		}
	}
	static class KMP {
		private static final int R = 256;		//radix
		private int M;
		private String pat;
		private int[][] dfa;
		public KMP(String pattern){
			this.pat = pattern;
			M = pat.length();
			dfa = new int[R][M];
			dfa[pat.charAt(0)][0] = 1;
			for(int X=0, j=1; j<M; j++){
				for(int c=0; c<R; c++)
					dfa[c][j] = dfa[c][X];		//copy mismatch cases
				dfa[pat.charAt(j)][j] = j+1;	//set match case
				X = dfa[pat.charAt(j)][X];		//update restart state
			}
		}
		public int search(String txt){
			int i,j, N = txt.length();
			for(i=0, j=0; i<N && j<M; i++)
				j = dfa[txt.charAt(i)][j];
			if(j==M) return i-M;
			else return N;
		}
	}
}