Little girl Tanya climbs the stairs inside a multi-storey building. Every time Tanya climbs a stairway, she starts counting steps from 1 to the number of steps in this stairway. She speaks every number aloud. For example, if she climbs two stairways, the first of which contains 3 steps, and the second contains 4 steps, she will pronounce the numbers 1, 2, 3, 1, 2, 3, 4.

You are given all the numbers pronounced by Tanya. How many stairways did she climb? Also, output the number of steps in each stairway.

The given sequence will be a valid sequence that Tanya could have pronounced when climbing one or more stairways.

Input

The first line contains n (1 ≤ n ≤ 1000) — the total number of numbers pronounced by Tanya.

The second line contains integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ 1000) — all the numbers Tanya pronounced while climbing the stairs, in order from the first to the last pronounced number. Passing a stairway with x steps, she will pronounce the numbers 1, 2, ..., x in that order.

The given sequence will be a valid sequence that Tanya could have pronounced when climbing one or more stairways.

Output

In the first line, output t — the number of stairways that Tanya climbed. In the second line, output t numbers — the number of steps in each stairway she climbed. Write the numbers in the correct order of passage of the stairways.

Examples

Input

7
1 2 3 1 2 3 4


Output

2
3 4 

Input

4
1 1 1 1


Output

4
1 1 1 1 

Input

5
1 2 3 4 5


Output

1
5 

Input

5
1 2 1 2 1


Output

3
2 2 1 
import java.io.*;
import java.math.*;
import java.util.*;

public class SuperClassss{

    //ЗАПУСКАЕМ РЕШЕНИЕЕЕЕ
    static class Run{
        static void myMain(){
            int n = nextInt(), last, k=-1, ans=0;
            ArrayList<Integer> a = new ArrayList<>();
            for(int i = 0; i<n; i++){
                last = k;
                k = nextInt();
                if(k==1){
                    ans++;
                    if(i>0) a.add(last);
                }
            }
            a.add(k);
            println(ans);
            for(int x:a) print(x+" ");
        }
    }

    public static void main(String[] args) {
        Run.myMain();
        out.flush();
    }

    static Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
    static PrintWriter out = new PrintWriter(System.out);
    static StreamTokenizer in1 = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
    static BufferedReader in2 = new BufferedReader(new InputStreamReader(System.in));

    /**
     * вывод в консоль
     **/
    public static <T> void print(T... args) {
        for (T x : args) {
            out.print(x.toString());
        }
    }

    /**
     * вывод в консоль
     **/
    public static <T> void println(T... args) {
        print(args);
        print("\n");
    }

    /**
     * Чтение числа типа long
     **/
    public static long nextLong() {
        try {
            in1.nextToken();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return (long) in1.nval;
    }

    /**
     * Чтение числа типа int
     **/
    public static int nextInt() {
        try {
            in1.nextToken();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return (int) in1.nval;
    }
    /**
     * Чтение строки
     **/

    static String nextLine(){
        return in.nextLine();
    }
    public static String nextString() {
        try {
            return in2.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return null;
    }

    /**
     * Чтение символа
     **/
    public static char nextChar() {
        try {
            return (char) in2.read();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return '!';
    }

    /**
     * Чтение массива чисел типа int
     **/
    public static void readArray(int[] array) {
        for (int i = 0; i < array.length; i++)
            array[i] = nextInt();
    }

    /**
     * Чтение массива чисел типа long
     **/
    public static void readArray(long[] array) {
        for (int i = 0; i < array.length; i++)
            array[i] = nextInt();
    }

    /**
     * Чтение массива типа char
     **/
    public static void readArray(char[] array) {
        for (int i = 0; i < array.length; i++)
            array[i] = nextChar();
    }

    /**
     * Чтение массива типа String
     **/
    public static void readArray(String[] array) {
        for (int i = 0; i < array.length; i++)
            array[i] = nextString();
    }

    /**
     * Чтение массива типа StringBuilder
     **/
    public static void readArray(StringBuilder[] array) {
        for (int i = 0; i < array.length; i++)
            array[i] = new StringBuilder(nextString());
    }

    /**
     * НОД чисел a и b
     **/
    public static int gcd(int a, int b) {
        while (b != 0) {
            int tmp = a % b;
            a = b;
            b = tmp;
        }
        return a;
    }

    /**
     * НОК чисел a и b
     **/
    public static int lcm(int a, int b) {
        return a / gcd(a, b) * b;
    }

    public static int min(int...args){
        Arrays.sort(args);
        return (args[0]);
    }

    public static int max(int...args){
        Arrays.sort(args);
        return(args[args.length-1]);
    }
    /**
     * Возвращает площадь треугольника с вершинами в точках (x1;y1), (x2;y2), (x3;y3)
     **/
    static double s(int x1, int y1, int x2, int y2, int x3, int y3) {
        return Math.abs((x2 - x1) * (y3 - y1) - (y2 - y1) * (x3 - x1)) / 2.0;
    }

    /**
     * Возвращает список с простыми числами от 2 до N
     * ---
     * На основе решета Эратосфена
     */
    public static LinkedList<Integer> isPrimeList(int n) {
        LinkedList<Integer> res = new LinkedList<>();
        boolean prime[] = new boolean[n];
        Arrays.fill(prime, true);
        prime[1] = false;
        for (int i = 2; i * i < n; i++) {
            if (prime[i])
                for (int j = i * i; j < n; j += i)
                    prime[j] = false;
        }
        for (int i = 2; i < n; i++)
            if (prime[i]) res.add(i);
        return res;
    }

    /**
     * Вычисляет квадратный корень из длинного числа
     * ---
     * методом Ньютона
     */
    public static BigInteger bigSqrt(BigInteger n) {
        BigInteger a = BigInteger.ONE.shiftLeft((n.bitLength() + 1) / 2), next = a.subtract(BigInteger.ONE);
        while (next.compareTo(a) < 0) {
            a = next;
            next = a.add(n.divide(a)).divide(BigInteger.valueOf(2));
        }
        return a;
    }
}