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.
The first line contains $n$ ($1 \le n \le 1000$) — the total number of numbers pronounced by Tanya.

The second line contains integers $a_1, a_2, \dots, a_n$ ($1 \le a_i \le 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, \dots, x$ in that order.

The given sequence will be a valid sequence that Tanya could have pronounced when climbing one or more stairways.
7
1 2 3 1 2 3 4
2
3 4 
4
1 1 1 1
4
1 1 1 1 
5
1 2 3 4 5
1
5 
5
1 2 1 2 1
3
2 2 1 
1
1
1
1 
48
1 2 3 4 1 2 3 1 1 2 3 1 2 3 4 1 1 2 3 4 1 2 3 4 1 2 3 4 1 1 2 1 2 1 2 1 1 2 1 2 1 2 3 1 2 1 2 1
20
4 3 1 3 4 1 4 4 4 1 2 2 2 1 2 2 3 2 2 1 
2
1 2
1
2 
3
1 1 2
2
1 2 
4
1 1 2 3
2
1 3 
8
1 2 3 1 2 3 4 5
2
3 5 
5
1 1 1 2 3
3
1 1 3 
# Bismillah
##############################
#      author: oneku16       #
#  trying to solve problems  #
##############################


import os
import sys
from io import BytesIO, IOBase
from typing import Any

from collections import Counter, deque, defaultdict
from itertools import accumulate, starmap
from bisect import bisect, bisect_left, bisect_right
from functools import reduce, wraps, lru_cache, cache
from heapq import heappush, heappop, heapify
from string import ascii_lowercase


BUFFER_SIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFFER_SIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self, **kwargs):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFFER_SIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin = IOWrapper(sys.stdin)
sys.stdout = IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

read_int = lambda: int(input())
read_ints = lambda _tuple=False: tuple(map(int, input().split())) if _tuple else map(int, input().split())
read_nums = lambda _sort=False, _reverse=False: list(map(int, input().split())) if not _sort else sorted(list(map(int, input().split())), reverse=_reverse)
read_str = lambda: str(input())
read_strs = lambda: map(str, input().split())
read_list_str = lambda: list(map(str, input().split()))

output = lambda value: sys.stdout.write(' '.join(map(str, value)) + "\n") if isinstance(value, (list, set, tuple)) else sys.stdout.write(f"{value}\n")

MAX = 1_000_000_007
MIN = -1_000_000_007

yes_no = lambda _status: "Yes" if _status else "No"
alice_bob = lambda _status: "Alice" if _status else "Bob"
int_to_bin = lambda num: bin(num).replace("0b", "")

"""

"""


def solve() -> Any:

    n = read_int()
    nums = read_nums()

    answer = [nums[0]]
    cnt = 1
    for i in range(1, n):
        if nums[i] - 1 != answer[-1]:
            answer.append(1)
        else:
            answer[-1] += 1
    output(len(answer))
    return answer


def main() -> None:
    for _ in range(1):
        output(solve())
    # solve()
    # output(solve())


if __name__ == "__main__":
    main()
