#include <bits/stdc++.h>
using namespace std;
long long int i, j, k, l, n, m, q, t, u, w, x, c;
long long int lit_time[100010];
long long int b[100010];
long long int a[100010];
int main() {
  cin >> n;
  c = 0;
  k = 0;
  memset(b, 0, sizeof b);
  long long int start = 1;
  for (i = (int)1; i < (int)n + 1; i++) {
    cin >> a[i];
    if (a[i] <= a[i - 1] && i > 1) {
      c++;
      b[c] = i - start;
      start = i;
    }
  }
  c++;
  b[c] = i - start;
  cout << c << "\n";
  for (i = (int)0; i < (int)c; i++) {
    cout << b[i + 1] << " ";
  }
}
