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

public class Q1 
{

	static class Pair implements Comparable<Pair> 
	{
		int u;
		int v;

		public Pair() 
		{

		}

		public Pair(int u, int v) 
		{
			this.u = u;
			this.v = v;
		}

		public int hashCode() 
		{
			int hu = (int) (u ^ (u >>> 32));
			int hv = (int) (v ^ (v >>> 32));
			return 31 * hu + hv;
		}

		public boolean equals(Object o) 
		{
			Pair other = (Pair) o;
			return (u == other.u && v == other.v);
		}

		public int compareTo(Pair other) 
		{
			return Long.compare(u, other.u) != 0 ? (Long.compare(u, other.u))
					: (Long.compare(v, other.v));
		}

		public String toString() 
		{
			return "[u=" + u + ", v=" + v + "]";
		}
	}
	
    static class FastScanner 
    {
	    private InputStream stream;
	    private byte[] buf = new byte[1024];
	    private int curChar;
	    private int numChars;
	    private SpaceCharFilter filter;
	 
	    public FastScanner(InputStream stream) 
	    {
	        this.stream = stream;
	    }
	 
	    public static boolean isWhitespace(int c) 
	    {
	        return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
	    }
	 
	    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 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 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 String nextToken() 
	    {
	        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 boolean isSpaceChar(int c) 
	    {
	        if (filter != null)
	            return filter.isSpaceChar(c);
	        return isWhitespace(c);
	    }
	 
	    public interface SpaceCharFilter 
	    {
	        public boolean isSpaceChar(int ch);
	    }
	}
    
    static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	static PrintWriter pw = new PrintWriter(new OutputStreamWriter(System.out));
	
	public static void main(String[] args) throws Exception 
	{
		FastScanner fs = new FastScanner(System.in);
		int n = fs.nextInt();
		int[] arr = new int[n];
		for(int i=0; i<n; i++)
			arr[i] = fs.nextInt();
		
		int numStairs = 0;
		ArrayList<Integer> maxStairs = new ArrayList<Integer>();
		if(n == 1) 
		{
			pw.println(1);
			pw.println(1);
			pw.flush();
			pw.close();
			return;
		}
		
		for(int i=0; i<n; i++)
			if(arr[i] == 1)
				numStairs++;
		
		for(int i=1; i<n-1; i++)
			if(arr[i] == 1)
				maxStairs.add(arr[i-1]);
		
		if(arr[n-1] == 1)
		{
			maxStairs.add(arr[n-2]);
			maxStairs.add(arr[n-1]);
		}
		else
			maxStairs.add(arr[n-1]);
		
		pw.println(numStairs);
		for(int i=0; i<maxStairs.size(); i++)
			pw.print(maxStairs.get(i) + " ");
		pw.flush();
		pw.close();
	}
}
