#include <bits/stdc++.h>
using namespace std;
int a[1005];
vector<int> v;
int main() {
  ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  int dem = 1;
  a[n] = -1;
  for (int i = 0; i < n; i++) {
    if (a[i] < a[i + 1])
      dem++;
    else {
      v.push_back(dem);
      dem = 1;
    }
  }
  cout << v.size() << endl;
  for (int i = 0; i < v.size(); i++) {
    cout << v[i] << " ";
  }
}
