#include <bits/stdc++.h>
using namespace std;
int main() {
  int ara[1010], i, c = 0, j = 0, p, n;
  vector<int> v;
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> ara[i];
  }
  if (n == 1) {
    cout << "1" << endl;
    cout << ara[0] << endl;
  } else {
    for (i = 0; i < n - 1; i++) {
      if (ara[i + 1] > ara[i])
        c++;
      else {
        v.push_back(c + 1);
        c = 0;
      }
      if (i == n - 2) {
        v.push_back(c + 1);
      }
    }
    p = v.size();
    cout << p << endl;
    for (i = 0; i < p; i++) {
      cout << v[i] << " ";
    }
    v.clear();
  }
}
