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.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
import java.util.StringTokenizer;
import java.util.Vector;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.stream.IntStream;

/**
 *
 * @author Aniis
 */
public class Main {

    public static void main(String[] args) {
        InputStream inputStream = null;
        /*    try {
            inputStream = new FileInputStream("test.txt");
        } catch (IOException e) {
           throw new RuntimeException(e);
        }*/
        OutputStream outputStream = System.out;
        FastScanner in = new FastScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        FuckTheWorld solver = new FuckTheWorld();
        solver.solve(1, in, out);
        out.close();
    }

static boolean allCharactersSame(String s) 
{ 
    int n = s.length(); 
    for (int i = 1; i < n; i++) 
        if (s.charAt(i) != s.charAt(0)) 
            return false; 
          
    return true; 
} 
 static long countDivisibles(long A, long B, long K) {
long firstDivisible = A%K == 0 ? A : A + (K - A%K);
        long lastDivisible = B%K == 0 ? B : B - B%K; //B/K behaves this way by default.
        return (lastDivisible - firstDivisible)/K + 1;
    }
  static String join(String x, String y){

   Set<Character> cx=new HashSet<Character>();
   Set<Character> cy=new HashSet<Character>();

   for (int k=0;k<x.length();k++)
       cx.add(x.charAt(k));

   for (int k=0;k<y.length();k++)
       cy.add(y.charAt(k));

   String result="";

   for (Character common: cx)
       if (cy.contains(common))
           result+=common;

   return result;
 }
   static String swap(String str, int i, int j) 
    { 
        if (j == str.length() - 1) 
            return str.substring(0, i) + str.charAt(j) 
             + str.substring(i + 1, j) + str.charAt(i); 
  
        return str.substring(0, i) + str.charAt(j) 
               + str.substring(i + 1, j) + str.charAt(i)  
               + str.substring(j + 1, str.length()); 
    }
   static int count(final String string, final String substring)
  {
     int count = 0;
     int idx = 0;

     while ((idx = string.indexOf(substring, idx)) != -1)
     {
        idx++;
        count++;
     }

     return count;
  }
   static  int search(String a)
{
	int ans = 0;
	for(int i=1;i<a.length();i++)
	{
		int flag = 1;
		for(int j=i;j<a.length();j++)
		{
			if(a.charAt(j)!=a.charAt(j-i))
			{
				flag = 0;
				break;
			 } 
		}
			ans = i;
		if(flag ==1) 
		{
			return ans; 
		}
	}
	return ans+1;
}
   
static int countUniqueCharacters(String input) {
    boolean[] isItThere = new boolean[Character.MAX_VALUE];
    for (int i = 0; i < input.length(); i++) {
        isItThere[input.charAt(i)] = true;
    }

    int count = 0;
    for (int i = 0; i < isItThere.length; i++) {
        if (isItThere[i] == true){
            count++;
        }
    }

    return count;
}
 static int count(String s, char c) 
    { 
        int res = 0; 
  
        for (int i=0; i<s.length(); i++) 
        { 
            // checking character in string 
            if (s.charAt(i) == c) 
            res++; 
        }  
        return res; 
    } 
    static class FuckTheWorld {

      public void solve(int testNumber, FastScanner in, PrintWriter out) {
    
        int     n = in.nextInt();
        int []p = new int[n];
        int k=0;
        Vector v = new Vector();
          for (int i = 0; i < n; i++) {
              int a =in.nextInt();
              p[i]=a;
              if(a==1) k++;
          }
          for (int i = 0; i < n-1; i++) {
              if(p[i]>=p[i+1]) v.add(p[i]);
          }
          v.add(p[n-1]);
          System.out.println(k);
          for (int i = 0; i < v.size(); i++) {
              System.out.print(v.elementAt(i)+" ");
          }
      }    
    }
    static class FastScanner {

        private BufferedReader br;
        private StringTokenizer st;

        public FastScanner(InputStream inputStream) {
            //br = new BufferedReader (new InputStreamReader(inputStream));
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        public String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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