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

public class A {

    //static FastInput k = new FastInput("/home/rajkin/Desktop/input.txt");
    static FastInput k = new FastInput(System.in);
    static FastOutput z = new FastOutput();
    static int n;
    static int [] y;
    static ArrayList<Integer> ans;
       
    static void startAlgorithm() {
		for(int i = 0; i<n-1; i++) {
			if(y[i] < y[i+1]) {
				continue;
			}
			else {
				ans.add(y[i]);
			}
		}
		
		ans.add(y[n-1]);
		z.println(ans.size());
		
		for(int i = 0; i<ans.size(); i++) {
			z.print(ans.get(i)+" ");
		}
		
		z.println();
    }
	
	static void getInputsAndInitializes() {
		n = k.nextInt();
		y = new int[n];
		ans = new ArrayList<Integer>();
		
		for(int i = 0; i<n; i++) {
			y[i] = k.nextInt();
		}
    }
    
	public static void main(String [] args) throws FileNotFoundException {        
		
		while(k.hasNext()) {
        	getInputsAndInitializes();
        	startAlgorithm();
        }
        z.flush();
        System.exit(0);
	}
	
	
	/* MARK: Pair implementation */
	
	public static class Pair {
		long leftNodes, rightNodes;
		public Pair(long leftNodes, long rightNodes) {
			this.leftNodes = leftNodes;
			this.rightNodes = rightNodes;
		}
	}
	
	
	/* MARK: SetBit implementation */
	
	public static long setBit(long pos, long value) {
		return value |= (1l << pos);
	}
	
    /* MARK: FastInput and FastOutput implementation */
	 
    public static class FastInput {
        BufferedReader reader;
        StringTokenizer tokenizer;
 
        public FastInput(InputStream stream){
            reader = new BufferedReader(new InputStreamReader(stream));
        }
        
	    public FastInput(String path){
	        try {
	        	reader = new BufferedReader(new FileReader(path));
			} catch (FileNotFoundException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
	        tokenizer = null;
	    }
 
        public String next() {
            return nextToken();
        }
        
        public String nextLine() {
            try {
				return reader.readLine();
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
            
            return null;
        }
 
        public boolean hasNext(){
            try {
                return reader.ready();
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            return false;
        }
 
        public String nextToken() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                String line = null;
                try {
                    line = reader.readLine();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
                if (line == null) {
                    return null;
                }
                tokenizer = new StringTokenizer(line);
            }
            return tokenizer.nextToken();
        }
 
        public Integer nextInt() {
            return Integer.parseInt(nextToken());
        }
       
        public Long nextLong() {
            return Long.valueOf(nextToken());
        }
    	
    	public void inputIntegerList(ArrayList<Integer> list, int size) {
    		for(int i = 0; i<size; i++) {
    			list.add(nextInt());
    		}
    	}
    	
    	public void inputLongList(ArrayList<Long> list, int size) {
    		for(int i = 0; i<size; i++) {
    			list.add(nextLong());
    		}
    	}
    	
    	public void inputWordList(ArrayList<String> list, int size) {
    		for(int i = 0; i<size; i++) {
    			list.add(next());
    		}
    	}
    	
    	public void inputLineList(ArrayList<String> list, int size) {
    		for(int i = 0; i<size; i++) {
    			list.add(nextLine());
    		}
    	}
    	
    	public void inputIntegerArray(int [] array, int size) {
    		for(int i = 0; i<size; i++) {
    			array[i] = nextInt();
    		}
    	}

    	public void inputLongArray(long [] array, int size) {
    		for(int i = 0; i<size; i++) {
    			array[i] = nextLong();
    		}
    	}
    	
    	public void inputWordArray(String [] array, int size) {
    		for(int i = 0; i<size; i++) {
    			array[i] = next();
    		}
    	}
    	
    	public void inputLineArray(String [] array, int size) {
    		for(int i = 0; i<size; i++) {
    			array[i] = nextLine();
    		}
    	}
    }
 
    public static class FastOutput extends PrintWriter {
    	public FastOutput() { 
            super(new BufferedOutputStream(System.out)); 
    	}
    	
    	public void printSideBySideSet(Set<Object> set, int size) {
    		boolean isFirstElementPrinted = false;
    		for(Object element : set) {
    			if(!isFirstElementPrinted) {
    				print(element);
    				isFirstElementPrinted = true;
    				
    				return;
    			}
    			print(" "+element);
    		}
    		println();
    	}
    	
    	public void printLineByLineSet(Set<Object> set, int size) {
    		for(Object element : set) {
    			println(element);
    		}
    	}
    	
    	public void printSideBySideList(ArrayList<Object> list, int size) {
    		print(list.get(0));
    		for(int i = 1; i<size; i++) {
    			print(" "+list.get(i));
    		}
    		println();
    	}
    	
    	public void printLineByLineList(ArrayList<Object> list, int size) {
    		for(int i = 0; i<size; i++) {
    			println(list.get(i));
    		}
    	}
    	
    	public void printSideBySideArray(Object [] array, int size) {
    		print(array[0]);
    		for(int i = 1; i<size; i++) {
    			print(" "+array[i]);
    		}
    		println();
    	}
    	
    	public void printLineByLineArray(Object [] array, int size) {
    		for(int i = 0; i<size; i++) {
    			println(array[i]);
    		}
    	}
    }
}