#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  int stair[t + 5];
  for (int i = 1; i <= t; i++) cin >> stair[i];
  int step = 0;
  int Count = 0;
  vector<int> store;
  for (int i = 1; i <= t; i++) {
    step++;
    if (stair[i] >= stair[i + 1] && i != t) {
      store.push_back(step);
      step = 0;
      Count++;
    }
  }
  store.push_back(step);
  cout << Count + 1 << endl;
  for (int i = 0; i < store.size(); i++) cout << store[i] << " ";
}
