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.io.*;
import java.util.*;

/**
 *
 * @author jlpaezs
 */
public class Snacktower {

    /**
     * @param args the command line arguments
     * @throws java.io.FileNotFoundException
     */
    public static void main(String[] args) throws FileNotFoundException {
        In in = new In();

        int n = in.nextInt();

        int[] ints = in.nextInts();

        MonticuloBinario<Integer> cola = new MonticuloBinario<>(ints.length, (o1, o2) -> Integer.compare(o2, o1));

        int c = n;
        for (int i = 0; i < ints.length; i++) {
            int aInt = ints[i];
            cola.insert(aInt);

            while (!cola.isEmpty() && cola.findMin() == c) {
                System.out.print(cola.deleteMin());
                System.out.print(" ");
                c--;
            }

            System.out.println("");
        }
    }

    private static class MonticuloBinario<AnyType extends Comparable<? super AnyType>> {

        private static final int DEFAULT_CAPACITY = 10;
        private int currentSize; // Number of elements in heap
        private AnyType[] array; // The heap array
        private Comparator<AnyType> comparador;

        /**
         * Construct the binary heap.
         */
        MonticuloBinario() {
            this(DEFAULT_CAPACITY);
        }

        MonticuloBinario(int capacity) {
            this(DEFAULT_CAPACITY, (AnyType o1, AnyType o2) -> o1.compareTo(o2));
        }

        /**
         * Construct the binary heap.
         *
         * @param capacity the capacity of the binary heap.
         * @param comparador
         */
        @SuppressWarnings("unchecked")
        MonticuloBinario(int capacity, Comparator<AnyType> comparador) {
            currentSize = 0;
            array = (AnyType[]) new Comparable[capacity + 1];
            this.comparador = comparador;
        }

        /**
         * Construct the binary heap given an array of items.
         *
         * @param items
         */
        @SuppressWarnings("unchecked")
        MonticuloBinario(AnyType[] items) {
            currentSize = items.length;
            array = (AnyType[]) new Comparable[(currentSize + 2) * 11 / 10];

            int i = 1;
            for (AnyType item : items) {
                array[i++] = item;
            }
            buildHeap();
        }

        /**
         * Insert into the priority queue, maintaining heap order. Duplicates
         * are allowed.
         *
         * @param x the item to insert.
         */
        public void insert(AnyType x) {
            if (currentSize == array.length - 1) {
                enlargeArray(array.length * 2 + 1);
            }

            // Percolate up
            int hole = ++currentSize;
            for (array[0] = x; comparador.compare(x, array[hole / 2]) < 0; hole /= 2) {
                array[hole] = array[hole / 2];
            }
            array[hole] = x;
        }

        private void enlargeArray(int newSize) {
            AnyType[] old = array;
            array = (AnyType[]) new Comparable[newSize];
            System.arraycopy(old, 0, array, 0, old.length);
        }

        /**
         * Find the smallest item in the priority queue.
         *
         * @return the smallest item, or throw an UnderflowException if empty.
         */
        public AnyType findMin() {
            if (isEmpty()) {
                throw new IllegalStateException();
            }
            return array[1];
        }

        /**
         * Remove the smallest item from the priority queue.
         *
         * @return the smallest item, or throw an UnderflowException if empty.
         */
        public AnyType deleteMin() {
            AnyType minItem = findMin();
            array[1] = array[currentSize--];
            percolateDown(1);

            return minItem;
        }

        /**
         * Establish heap order property from an arbitrary arrangement of items.
         * Runs in linear time.
         */
        private void buildHeap() {
            for (int i = currentSize / 2; i > 0; i--) {
                percolateDown(i);
            }
        }

        /**
         * Test if the priority queue is logically empty.
         *
         * @return true if empty, false otherwise.
         */
        public boolean isEmpty() {
            return currentSize == 0;
        }

        /**
         * Make the priority queue logically empty.
         */
        public void makeEmpty() {
            currentSize = 0;
        }

        /**
         * Internal method to percolate down in the heap.
         *
         * @param hole the index at which the percolate begins.
         */
        private void percolateDown(int hole) {
            int child;
            AnyType tmp = array[hole];

            for (; hole * 2 <= currentSize; hole = child) {
                child = hole * 2;
                if (child != currentSize
                        && comparador.compare(array[child + 1], (array[child])) < 0) {
                    child++;
                }
                if (comparador.compare(array[child], (tmp)) < 0) {
                    array[hole] = array[child];
                } else {
                    break;
                }
            }
            array[hole] = tmp;
        }
    }

    private static class In {

        private final Scanner scan;

        In() throws FileNotFoundException {
            File f = new File("Snacktower.in");
            if (f.exists()) {
                this.scan = new Scanner(f);
            } else {
                this.scan = new Scanner(System.in);
            }
        }

        public int nextInt() {
            return Integer.parseInt(scan.nextLine());
        }

        public long nextLong() {
            return Long.parseLong(scan.nextLine());
        }

        public String nextString() {
            return scan.nextLine();
        }

        public int[] nextInts() {
            String[] line = scan.nextLine().split(" ");
            int[] ints = new int[line.length];

            for (int i = 0; i < ints.length; i++) {
                ints[i] = Integer.parseInt(line[i]);
            }
            return ints;
        }

        public long[] nextLongs() {
            String[] line = scan.nextLine().split(" ");
            long[] longs = new long[line.length];

            for (int i = 0; i < longs.length; i++) {
                longs[i] = Long.parseLong(line[i]);
            }
            return longs;
        }

        public String[] nextStrings() {
            return scan.nextLine().split(" ");
        }

        public double[] nextDoubles() {
            String[] line = scan.nextLine().split(" ");
            double[] doubles = new double[line.length];

            for (int i = 0; i < doubles.length; i++) {
                doubles[i] = Double.parseDouble(line[i]);
            }
            return doubles;
        }

    }

}