#include<iostream>
using namespace std;//
int main()
{
    int n;
    cin>>n;
    int a[n],b[n],ind=0,m=1;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    int ans=0;
    for(int i=1;i<n;i++)
    {
        if(a[i]<=a[i-1])
        {
            b[ind]=m;
            m=0,ind++;
            ans++;
        }
    }
    cout<<ans<<endl;
    for(int i=0;i<ind;i++)
    cout<<b[i]<<endl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int n,sum,a[10001];
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++) cin>>a[i];
	for(int i=1;i<=n;i++) if(a[i]==1) sum++;
	cout<<sum<<endl;
	for(int i=1;i<n;i++) if(a[i+1]==1) cout<<a[i]<<" ";
    cout<<a[n];
	return 0
}


#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int a,s[10001];
long long ans=0;
int main()
{
	scanf("%d",&a);
	for(int i=1;i<=a;i++)
	{
		scanf("%d",&s[i]);
		if(s[i]==1)ans++;
	}
	cout<<ans<<endl;
	for(int i=1;i<=a;i++)
	{
		if(s[i+1]-s[i]!=1)
		cout<<s[i]<<" ";
	}
	return 0;
}


#include<iostream>
using namespace std;
int main()
{
    int n,p,sta[1010],top=0,cnt=1;
    cin>>n>>p;
    for(int i=1;i<n;i++)
    {
        int t;
        cin>>t;
        if(t==p+1)
        {
            cnt++;
            p++;
        }
        else
        {
            sta[top++]=cnt;
            p=t;
            cnt=1;
        }
    }
    sta[top++]=cnt;
    cout<<top<<'\n';
    for(int i=0;i<top;i++)
        cout<<sta[i]<<' ';
    return!(cout<<'\n');
}


#include<iostream>
using namespace std;
int n,last,i,x,num,a[1001];
int main()
{
	cin>>n;last=0;
	for(i=1;i<=n;++i)
	{
	cin>>x;
	if(x!=last+1)
		a[++num]=last;
	last=x;
	}
	if(x!=last+1)
		a[++num]=last;
	cout<<num<<endl;
	for(i=1;i<=num;++i)
	cout<<a[i]<<" ";
}


#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main() {
	int n,sum=0;
	cin>>n;
	int a[n+1],b[n+1];
	for(int i=1;i<=n;i++){
		cin>>a[i];
		if(a[i]==1){
			sum++;
		}
		b[sum]++;
	}
	cout<<sum<<endl;
	for(int i=1;i<=sum;i++){
		cout<<b[sum]<<" ";
	}

	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int a,b,c,d[1001],e,f;
int main()
{
	cin>>a;
	for(;c<a;c++)
	{
		cin>>b;
		if(b==1&&c)
		{
			d[e++]=f;
			f=0;
		}
		f++;
	}
	cout<<e+1<<endl;
	for(c=0;c<e;)
	{
		cout<<d[c++]<<" ";
	}
	cout<<f;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int a[1001],b,sum;
int main()
{
	cin>>b;
	for(int i=1;i<=b;i++)
	{
		cin>>a[i];
		if(a[i]==1)
		{
			sum++;
		}
	}
	cout<<sum<<endl;
	for(int i=1;i<=b;i++)
	{
		if(a[i+1]==1)
		{
			cout<<a[i]<<" ";
		}
	}
	cout<<a[b]<<endl;
	return 0;
}


//author Eterna
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cstring>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<utility>
#include<cmath>
#include<climits>
#include<deque>
#include<functional>
#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
#define INF 0x7fffffff
#define maxn 100000
#define eps 1e-15
#define MOD ((int)(1e9+7))
#define ABS(x) ((x)>=0?(x):(-(x)))
#define pb(x) push_back(x)
#define lowbit(x) (x&-x)
#define mid (L+R)/2
#define Lson (index*2)
#define Rson (index*2+1)
using namespace std;
typedef long long ll;
inline int read() {
	char c;
	int ret = 0, sgn = 1;
	do { c = getchar(); } while ((c < '0' || c > '9') && c != '-');
	if (c == '-') sgn = -1; else ret = c - '0';
	while ((c = getchar()) >= '0' && c <= '9') ret = ret * 10 + (c - '0');
	return sgn * ret;
}
int n, arr[1005], last;
queue<int> ans;
int main(void)
{
	n = read(); last = arr[1] = read();
	if (n == 1)ans.push(1);
	for (int i = 2; i <= n; i++) {
		arr[i] = read();
		if (arr[i] == 1) {
			ans.push(last);
			last = 1;
			if (i == n)ans.push(last);
		}
		else {
			last = arr[i];
			if (i == n)ans.push(last);
		}
	}
	cout << ans.size() << endl;
	while (ans.size()) {
		if (ans.size() == 1) {
			cout << ans.front() << endl; ans.pop();
		}
		else {
			cout << ans.front() << " "; ans.pop();
		}
	}
//	system("pause");
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int n,i,sum,a[1001];
int main(){
    cin>>n;
    while(cin>>a[++i])
        if(a[i]==1) sum++;
    cout<<sum<<endl;
    for(int i=1;i<n;i++)
        if(a[i+1]==1) cout<<a[i]<<" ";
    cout<<a[n]<<endl;
    return 0;
}


#include<iostream>
#include<cstdio>
using namespace std;
int n,i,a[1002],ans[1002],t=1;
int main()
{
	for(int i=1;i<=1000;i++)
	ans[i]=1;
	cin>>n;
	for(i=1;i<=n;i++)
	cin>>a[i];
	int p=1;
	while(p<=n)
	{
		if(a[p]==1)
		{
			 p++;
			 while(a[p]!=1&&p<=n)
	     	{
	     	   ans[t]++;
			   p++;
		    }
		    t++;
		}
	}
	cout<<t-1<<endl;
	for(i=1;i<t;i++)
	cout<<ans[i]<<' ';
	cout<<endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,a[1010],b[1010],ans=1;
    cin>>n>>a[0];
    for(int i=1;i<n;i++)
    {
           cin>>a[i];
           if(a[i]==1)
             b[ans++]=a[i-1];
    }
     cout<<ans<<endl;
     b[ans++]=a[n-1];
     for(int i=1;i<ans;i++)
        cout<<b[i]<<" ";
    return 0;


#include <bits/stdc++.h>
using namespace std;

int a[100005], cnt, n;

int main() {
    scanf("%d", &n);
    for (int i = 1; i <= n; i++)
        scanf("%d", &a[i]);
    a[n + 1] = 1;
    // count'
    for (int i = 1; i <= n; i++)
        if (a[i] == 1) cnt++;
    printf("%d\n", cnt);

    // print_group
    for (int i = 2; i <= n + 1; i++)
        if (a[i] == 1) printf("%d ", a[i - 1]);
    puts("");
    return 0;
}


#include <iostream>
using namespace std;
int main(){
    int a[1001],n,sum=0；
    cin>>n;
    for(int i=0;i<=n;i++) cin>>a[i];
    for(int i=0;i<=n;i++)
        if(a[i]==1) sum++；
    for(int i=0;i<n;i++)
        if(a[i+1]==1) cout<<a[i]<<" ";
    cout<<a[n]<<endl;
    return 0;
}


#include <cstdio>
#include <algorithm>
#include <cstring>
#include <queue>
#include <cmath>
#include <iostream>
using namespace std;

const int Maxn=100001;

int n,m;
int a[Maxn];

int main()
{
	cin>>n;
	for(int i=1; i<=n; i++) {
		cin>>a[i];
		if(a[i]==1)
			m++;
	}
	a[++n]=1;
	cout<<m<<endl;
	for(int i=2; i<=n+1; i++)
		if(a[i]==1)
		    cout<<a[i-1]<<' ';
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
    int a[1001],n,sum=0;
    cin>>n;
    for(int i=1;i<=n;i++)
        cin>>a[i];
    for(int i=1;i<=n;i++)
        if(a[i]==1)
            sum++;
    cout<<sum<<endl;
    for(int i=1;i<n;i++)
        if(a[i+1]==1)
            cout<<a[i]<<" ";
    cout<<a[n]<<endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,a[1010],b[1010],ans=1;
    cin>>n>>a[0];
    for(int i=1;i<n;i++)
    {
           cin>>a[i];
           if(a[i]==1)
             b[ans++]=a[i-1];
    }
     cout<<ans<<endl;
     b[ans++]=a[n-1];
     for(int i=1;i<ans;i++)
        cout<<b[i]<<" ";
    return 0;
}


#include<iostream>
using namespace std;
int main() {
    int c, d[10000], g = 0;
    cin >> c;
    for (int i = 0; i < c; i++) {
        cin >> d[i];
        if (d[i] == 1) g++;
    }
    cout << g << endl;
    for (int i = 1; i < c; i++) if (d[i] == 1) cout << d[i - 1] << " ";
    cout << d[c - 1] << endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int n,a[1001],ans=1,cnt[1001],k=1;
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	cnt[1]=1;
	for(int i=2;i<=n;i++){
		if(a[i]==1){
			ans++;
		}
		cnt[ans]++;
	}
	printf("%d\n",ans);
	for(int i=1;i<=ans;i++){
		printf("%d ",cnt[i]);
	}
	return 0;
}


#include<cmath>
#include<cstdio>
#include<string>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
int n,ans=1,k[1005];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&k[i]);
	}
	for(int i=1;i<=n;i++)
	{
		if(k[i]>=k[i+1])
		{
			printf("%d ",ans);
			ans=0;
		}
		ans++;
	}
	return 0;
}


#include<bits/stdc++.h>
int main()
{
	int n,sum=0,a[1005],b[1005];cin>>n;
	for(int i=1;i<=n;i++) std::cin>>a[i];
	for(int i=1;i<=n;i++) if(a[i]==1) sum++;
	std::cout<<sum<<std::endl;
	for(int i=1;i<=n;i++) if(a[i]>=a[i+1]) std::cout<<a[i]<<" ";
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
int i,n,j,a,l,k,ans;
queue<int> q;
int main(){
	cin>>n;
	for(i=1;i<=n;i++){
		cin>>a;
		if(a==1&&k>0) ans++,q.push(k),k=0;
		else k++;
	}
	cout<<k<<endl;
	for(i=1;i<=q.size();i++){
		cout<<q.front()<<" ";
		q.push(q.front());
		q.pop();
	}
	return 0;
}


#include<cstdio>
using namespace std;
int main(){
    int a[1001],n,sum=0;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)scanf("%d",&a[i]);
    for(int i=1;i<=n;i++)if(a[i]==1) sum++;
    printf("%d\n",sum);
    for(int i=1;i<n;i++)if(a[i+1]==1)printf("%d ",a[i]);
    printf("%d",a[n]);
}


#include<iostream>
using namespace std;//
int main()
{
    int n;
    cin>>n;
    int a[n],b[n],ind=0,m=1;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    int ans=0;
    for(int i=1;i<n;i++)
    {
        if(a[i]<=a[i-1])
        {
            b[ind]=m;
            m=0,ind++;
            ans++;
        }
        m++;
    }
    b[ind]=m;
    ind++;
    cout<<ans+1<<endl;
    for(int i=0;i<ind;i++)
    cout<<b[i]<<" ";
    return 0;
}


#include<cstdio>
#define tin int
#define itn int
#define tni int
#define nit int
#define nti int
#define pritnf printf
#define scnaf scanf
#define retrun return
#define sizoef sizeof
#define ll long long
#define inl inline
#define br break
#define con continue
#define mst(a,b) memset(a,b,sizeof(a))
#define fora(x,a,b) for(re tin x=a;x<=b;++x)
#define forb(x,a,b) for(re itn x=a;x>=b;--x)
#define re register
#define str struct
#define infa 0x3f3f3f3f
#define infb 0x7fffffff
#define infc 1061109567
#define infd 0x7f
#define abss(x) (x>0?x:-x)
using namespace std;
const nit maxa=1004;
const nit maxb=204;
const nit maxc=70004;
#include<cstring>

nti n,x[maxa]={0},num[maxa]={0},ans=0,l=0;

itn main()
{
	scanf("%d",&n);
	fora(i,1,n)
	{
		scanf("%d",&x[i]);
		if(x[i]>x[i-1])
		{
			++l;
			con;
		}
		num[++num[0]]=l,l=1;
		++ans;
	}
	num[++num[0]]=l,l=0;
	++ans;
	//
	printf("%d\n",ans);
	fora(i,1,num[0])
	{
		printf("%d ",num[i]);
	}
	pritnf("\n");
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
long long n,a[100001],s,ans;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		if(a[i]==1)
		{
			s++;
		}
	}
	cout<<s<<endl;
	for(int i=1;i<=n;i++)
	{
		if(a[i+1]==1)
		{
			cout<<a[i]<<" ";
		}
	}
	cout<<a[n];
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int n,num,cnt=0,ans[1005]={0};
int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>num;
		if(num!=1||i==1){
			cnt++;
		}else if(num==1){
			ans[0]++;
			ans[ans[0]]=cnt;
			cnt=1;
		}
	}
	cout<<++ans[0]<<endl;
	for(int i=1;i<ans[0];i++){
		cout<<ans[i]<<" ";
	}
	cout<<cnt<<endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int n,ans,num[1000];
int main()
{
	cin>>n;
	for(int i=0;i<n;i+=1)
	{
		cin>>num[i];
		if(num[i]==1)
			ans+=1;
	}
	cout<<ans<<endl;
	for(int i=0;i<n-1;i+=1)
		if(num[i+1]==1)
			cout<<num[i]<<" ";
	cout<<num[n-1]<<endl;
	return 0;
}


#include<cstdio>
#include<cstdlib>
#include<vector>
using namespace std;

vector<int> g;

int main(){
    int n;
    int ans=0;
    scanf("%d",&n);
    int x; scanf("%d",&x);
    for(int i=1;i<=n;i++){
        scanf("%d",&x);
        if(x==1){
            g.push_back(ans);
            ans=0;
        }
        else ans=x;
    }
    g.push_back(x);
    printf("%d\n",g.size());
    for(int i=0;i<g.size();i++){
        printf("%d ",g[i]);
    }
    printf("\n");
    return 0;
}


#include<cstdio>
#include<cstdlib>
#include<vector>
using namespace std;

vector<int> g;

int main(){
    int n;
    int ans=1;
    scanf("%d",&n);
    int x; scanf("%d",&x);
    for(int i=1;i<=n;i++){
        scanf("%d",&x);
        if(x==1){
            g.push_back(ans);
            ans=0;
        }
        else ans=x;
    }
    if(x>1) g.push_back(x);
    printf("%d\n",g.size());
    for(int i=0;i<g.size();i++){
        printf("%d ",g[i]);
    }
    printf("\n");
    return 0;
}


#include<cstdio>
#include<cstdlib>
#include<vector>
using namespace std;

vector<int> g;

int main(){
    int n;
    int ans=0;
    int x;
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        scanf("%d",&x);
        if(x==1){
            g.push_back(ans);
            ans=0;
        }
        else ans=x;
    }
    printf("%d\n",g.size());
    for(int i=0;i<g.size();i++){
        printf("%d ",g[i]);
    }
    printf("\n");
    return 0;
}


#include<cstdio>
#include<cstdlib>

int main(){
    int n;
    int ans=0;
    int x;
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        scanf("%d",&x);
        ans++;
        if(x==1){
            printf("%d\n",ans);
            ans=1;
        }
    }
    return 0;
}


#include<cstdio>
#include<cstdlib>
#include<vector>
using namespace std;

vector<int> g;

int main(){
    int n;
    int ans=0;
    int x; scanf("%d",&x);
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        scanf("%d",&x);
        if(x==1){
            g.push_back(ans);
            ans=0;
        }
        else ans=x;
    }
    g.push_back(x);
    printf("%d\n",g.size());
    for(int i=0;i<g.size();i++){
        printf("%d ",g[i]);
    }
    printf("\n");
    return 0;
}


#include<cstdio>
#include<cstdlib>
#include<vector>
using namespace std;

vector<int> g;

int main(){
    int n;
    int ans=0;
    int x;
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        scanf("%d",&x);
        ans++;
        if(x==1){
            g.push_back(ans);
            ans=0;
        }
    }
    printf("%d",g.size());
    for(int i=0;i<g.size();i++){
        printf("%d ",g[i]);
    }
    printf("\n");
    return 0;
}


#include<cstdio>
#include<cstdlib>
#include<vector>
using namespace std;

vector<int> g;

int main(){
    int n;
    int ans=1;
    scanf("%d",&n);
    int x; scanf("%d",&x);
    for(int i=1;i<=n;i++){
        scanf("%d",&x);
        if(x==1){
            g.push_back(ans);
            ans=x;
        }
        else ans=x;
    }
    if(x>1) g.push_back(x);
    printf("%d\n",g.size());
    for(int i=0;i<g.size();i++){
        printf("%d ",g[i]);
    }
    printf("\n");
    return 0;
}


#include<iostream>
#include<vector>
using namespace std;

int main()
{
    int n; cin>>n;
    vector<int> arr;
    for(int i=0; i<n; i++)
    {
        int val; cin>>val;
        arr.push_back(val);
    }
    vector<int> out;
    for(int i=1;i<n;i++)
    {
        if(arr[i]<=arr[i-1])
        {
            out.push_back(arr[i-1])
        }
    }
    cout<<out.size()<<end;
    for(int i = 0; i<out.size(); i++)
    {
        cout<<out[i]<<" ";
    }
    return 0;
}


#include<iostream>
#include<vector>
using namespace std;

int main()
{
    int n; cin>>n;
    vector<int> arr;
    for(int i=0; i<n; i++)
    {
        int val; cin>>val;
        arr.push_back(val);
    }
    vector<int> out;
    for(int i=1;i<n;i++)
    {
        if(arr[i]<=arr[i-1])
        {
            out.push_back(arr[i-1]);
        }
    }
    cout<<out.size()<<end;
    for(int i = 0; i<out.size(); i++)
    {
        cout<<out[i]<<" ";
    }
    return 0;
}


#include<iostream>
#include<vector>
using namespace std;

int main()
{
    int n; cin>>n;
    vector<int> arr;
    for(int i=0; i<n; i++)
    {
        int val; cin>>val;
        arr.push_back(val);
    }
    vector<int> out;
    for(int i=1;i<n;i++)
    {
        if(arr[i]<=arr[i-1])
        {
            out.push_back(arr[i-1]);
        }
    }
    cout<<out.size()<<endl;
    for(int i = 0; i<out.size(); i++)
    {
        cout<<out[i]<<" ";
    }
    return 0;
}


#include<siostream>
#include<vector>
using namespace std;

int main()
{
    int n; cin>>n;
    vector<int> arr;
    for(int i=0; i<n; i++)
    {
        int val; cin>>val;
        arr.push_back(val);
    }
    vector<int> out;
    for(int i=1;i<n;i++)
    {
        if(arr[i]<=arr[i-1])
        {
            out.push_back(arr[i-1])
        }
    }
    cout<<out.size()<<end;
    for(int i = 0; i<out.size(); i++)
    {
        cout<<out[i]<<" ";
    }
    return 0;
}


#include<iostream>
#include<vector>
using namespace std;

int main()
{
    int n; cin>>n;
    vector<int> arr;
    for(int i=0; i<n; i++)
    {
        int val; cin>>val;
        arr.push_back(val);
    }
    arr.push_back(1);
    vector<int> out;
    for(int i=1;i<arr.size();i++)
    {
        if(arr[i]<=arr[i-1])
        {
            out.push_back(arr[i-1]);
        }
    }
    cout<<out.size()<<endl;
    for(int i = 0; i<out.size(); i++)
    {
        cout<<out[i]<<" ";
    }
    return 0;
}


#include <vector>
#include <iostream>

using namespace std;
int main()
{
    vector <int> v;
    int t = 0, n, in, c = 0;

    cin >> n;
    while(n--)
    {
        cin >> in;
        if(t > in)
        {
            c++;
            v.push_back(t);
        }

        t = in;
    }
    v.push_back(t);

    cout << c+1 << endl;
    for(vector <int>:: iterator it = v.begin(); it!=v.end(); it++)
        cout << *it << " ";
    return 0;
}


#include <vector>
#include <iostream>

using namespace std;
int main()
{
    int t = 0, n, in;
    vector <int> v;

    cin >> n;
    while(n--)
    {
        cin >> in;
        if(t > in)
            v.push_back(t);

        t = in;
    }
    v.push_back(t);

    for(vector <int>:: iterator it = v.begin(); it!=v.end(); it++)
        cout << *it << " ";
    return 0;
}


#include <vector>
#include <iostream>

using namespace std;
int main()
{
    vector <int> v;
    int t = 0, n, in, c = 0;

    cin >> n;
    while(n--)
    {
        cin >> in;
        if(t > in)
        {
            c++;
            v.push_back(t);
        }

        t = in;
    }
    v.push_back(t);

    cout << c << endl;
    for(vector <int>:: iterator it = v.begin(); it!=v.end(); it++)
        cout << *it << " ";
    return 0;
}


#include <vector>
#include <iostream>

using namespace std;
int main()
{
    vector <int> v;
    int t = 0, n, in, c = 0;

    cin >> n;
    while(n--)
    {
        cin >> in;
        if(in == 1 && t)
        {
            c++;
            v.push_back(t);
        }

        t = in;
    }
    v.push_back(t);

    cout << c+1 << endl;
    for(vector <int>:: iterator it = v.begin(); it!=v.end(); it++)
        cout << *it << " ";
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    int n;
    cin>>n;
    vector<int> lol;
    for(int i =0; i < n; i++)
    {
        int p;
        cin>>p;
        lol.push_back(p);
    }
   if(n==1)
   {
     cout<<1<<endl;
     cout<<1<<endl;
     return 0;
   }
    vector<int> lolz;
    for(int i = 1; i < n; i++)
    {
       if(lol[i]==1)
            lolz.push_back(lol[i-1]);
        if(i==n-1)
          lolz.push_back(lol[i]);

    }
    cout<<lolz.size()<<endl;
    for(int i = 0; i < lolz.size(); i++)
    {
      cout<<lolz[i]<<" ";
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    int n;
    cin>>n;
    vector<int> lol;
    for(int i =0; i < n; i++)
    {
        int p;
        cin>>p;
        lol.push_back(p);
    }
    vector<int> lolz;
    for(int i = 1; i < n; i++)
    {
       if(lol[i]==1)
            lolz.push_back(lol[i-1]);
        if(i==n-1)
          lolz.push_back(lol[i]);

    }
    cout<<lolz.size()<<endl;
    for(int i = 0; i < lolz.size(); i++)
    {
      cout<<lolz[i]<<" ";
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    int n;
    cin>>n;
    vector<int> lol;
    for(int i = 0; i < n; i++)
    {
        int p;
        cin>>p;
        lol.push_back(p);
    }
    if(n==1)
    {
        cout<<1<<endl;
        cout<<1<<endl;
        return 0;
    }
    vector<int> lolz;
    for(int i = 0; i < n; i++)
    {
        if(lol[i]==1)
            lolz.push_back(lol[i-1]);
        if(i==n-1)
            lolz.push_back(lol[i]);
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    int n;
    cin>>n;
    vector<int> lol;
    for(int i =0; i < n; i++)
    {
        int p;
        cin>>p;
        lol.push_back(p);
    }
   if(n==1)
   {
     cout<<1<<endl;
     return 0;
   }
    vector<int> lolz;
    for(int i = 1; i < n; i++)
    {
       if(lol[i]==1)
            lolz.push_back(lol[i-1]);
        if(i==n-1)
          lolz.push_back(lol[i]);

    }
    cout<<lolz.size()<<endl;
    for(int i = 0; i < lolz.size(); i++)
    {
      cout<<lolz[i]<<" ";
    }
    return 0;
}


#include <bits/stdc++.h>

using  namespace std;

int main(){
    int n;
    int a[1010];
    int b[1010];
    int j=1;
    memset(b,0,sizeof b);
    scanf("%d",&n);
    for(int i = 0; i<n; ++i){
        scanf("%d",&a[i]);
        int num=a[0];
        if(a[i]==a[0]&&i!=0){
            b[j]=a[i-1];
            j++;
        }
    }
    printf("%d\n",j);
    for(int i=0;i<j;i++){
     printf("%d ",b[i]+1);
     printf("%d",a[n]);
}

return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define maxx 1010
int a[maxx],b[maxx];
int main(){
    int n,count=0;
    scanf("%d",&n);
    for(int i = 0; i < n; ++i)
        scanf("%d",&a[i]);
    for(int i = 1; i < n; ++i){
        if(a[i] == 1){
            ++count;
            b[count]=a[i-1];
        }
    }
    printf("%d\n",count+1);
    for(int i = 1; i <= count; ++i)
        printf("%d ",b[i]);
    printf("%d\n",a[n-1]);
return 0;
}


#include <bits/stdc++.h>

using  namespace std;

#define maxx 1005
int a[maxx],b[maxx];
int main(){
    int n,count=0;
    scanf("%d",&n);
    scanf("%d",&a[0]);
    for(int i =1; i < n; ++i){
        scanf("%d",&a[i]);
    if(a[i] == 1){
        count++;
        b[count] = a[i-1];
    }
    }
    printf("%d\n",count+1);
    for(int i=1; i < count; ++i){
        printf("%d ",b[i]);
    printf("%d ",a[n-1]);
    }
return 0;
}


#include <bits/stdc++.h>

using  namespace std;

#define maxx 1005
int a[maxx],b[maxx];
int main(){
    int n,count=0;
    scanf("%d",&n);
    scanf("%d",&a[0]);
    for(int i =1; i < n; ++i){
        scanf("%d",&a[i]);
    if(a[i] == 1){
        count++;
        b[count] = a[i-1];
    }
    }
    printf("%d\n",count+1);
    for(int i=1; i <= count; ++i){
        printf("%d ",b[i]);
    printf("%d\n",a[n-1]);
    }
return 0;
}


#include <bits/stdc++.h>

using  namespace std;

#define maxx 1005
int a[maxx],b[maxx];
int main(){
    int n,count=0;
    scanf("%d",&n);
    scanf("%d",&a[0]);
    for(int i =1; i < n; ++i){
        scanf("%d",&a[i]);
    if(a[i] == 1){
        ++count;
        b[count] = a[i-1];
    }
    }
    printf("%d\n",count+1);
    for(int i=1; i <= count; ++i){
        printf("%d ",b[i]);
    printf("%d\n",a[n-1]);
    }
return 0;
}


//Muga Bogdan-Marius
#include <iostream>

using namespace std;

int main()
{
    int i,N,a[100],k=0;
    cin>>N;
    for(i=1;i<=N;i++)
        cin>>a[i];
    for(i=1;i<N;i++)
        if(a[i+1]==1)
            k++;
    cout<<k+1<<endl;
    for(i=1;i<N;i++)
        if(a[i+1]==1)
            cout<<a[i]<<" ";
    cout<<a[i];
    return 0;
}


#include <iostream>
#include <vector>
using namespace std;

int main(){
    int cnt = 1, cur, prev;
    vector<int> sol;
    int n;
    cin >> n;
    cin >> prev;

    for (int i = 2; i <= n; ++i){
        cin >> cur;
        if (cur == 1){
            cnt++;
            sol.push_back(prev);
        }
        prev = cur;
    }
    sol.push_back(cur);

    cout << cnt << '\n';
    for (it : sol)
        cout << it << ' ';

    return 0;
}


#include<bits/stdc++.h>

using namespace std;

int main(){

    int n , x , y , v[1001];
    int k = 0 ;
    cin >> n ;
    cin >> y ;

    if(n == 1 && y == 1)
    {
        cout << 1 << '\n' << 1;
        return 0;
    }

    for(int i = 0 ; i < n - 1 ; i++){
        cin >> x;
        if(x != y+1){
            v[k++] = y ;

        }
        y = x ;
    }

    v[k++] = x ;
    cout << k << endl;
    for(int  i = 0 ; i < k ; i ++)
    {
        cout << v[i] << " " ;
    }

}


//A_Theodora_Danciulescu_CE_2
#include <iostream>
#include <vector>

using namespace std;

int main(){

    int n; cin >> n;

    int v[1010];

    vector <int> sol;

    cin >> v[0];

    for( int i = 1; i < n ;i++){
        cin >> v[i];

        if( v[i] <= v[i - 1]){
            sol.push_back(v[i - 1]);
        }
    }

    sol.push_back(v[n-1]);

    cout << sol.size() << '\n';

    for( int i = 0; i < sol.size(); i++){
        cout << sol[i] << " ";
    }

}


#include<bits/stdc++.h>

using namespace std;

int main(){

    int n , x , y , v[1001];
    int k = 0 ;
    cin >> n ;
    cin >> y ;
    for(int i = 0 ; i < n - 1 ; i++){
        cin >> x;
        if(x != y+1){
            v[k++] = y ;

        }
        y = x ;
    }

    v[k++] = x ;
    cout << k << endl;
    for(int  i = 0 ; i < k ; i ++)
    {
        cout << v[i] << " " ;
    }

}


//Muga Bogdan-Marius
#include <iostream>

using namespace std;

int main()
{
    int i,N,a[10000],k=0;
    cin>>N;
    for(i=1;i<=N;i++)
        cin>>a[i];
    for(i=1;i<N;i++)
        if(a[i+1]==1)
            k++;
    cout<<k+1<<endl;
    for(i=1;i<N;i++)
        if(a[i+1]==1)
            cout<<a[i]<<" ";
    cout<<a[i];
    return 0;
}


#include <iostream>
#include <vector>
using namespace std;

int main(){
    int cnt = 1, cur, prev;
    vector<int> sol;
    int n;
    cin >> n;
    cin >> prev;

    if(n == 1 && prev == 1)
    {
        cout << 1 << '\n' << 1;
        return 0;
    }

    for (int i = 2; i <= n; ++i){
        cin >> cur;
        if (cur == 1){
            cnt++;
            sol.push_back(prev);
        }
        prev = cur;
    }
    sol.push_back(cur);

    cout << cnt << '\n';
    for (it : sol)
        cout << it << ' ';

    return 0;
}


#include <iostream>
#include <vector>

using namespace std;

int main()
{
    int x, n , c, y, counter = 0;
    vector<int> a, b;
    cin >> n;
    for( int i = 0 ; i < n ; i++ )
    {
        cin >> x;
        a.push_back(x);
        if( x==1)
            counter++;
    }

    cout << counter<< "\n";
    vector<int> ::iterator it;
    for( it = a.begin() ; it != a.end() ; it++ )
        if( *(it + 1) == 1 || it == a.end() - 1 )
            cout << *it << " ";
    return 0;
}


#include <iostream>
#include <vector>

using namespace std;

int main(){
    cout.tie(0);

    int n, nr_etaje = 0, a, b;
    cin >> n;
    vector<int>v;
    cin >> a;
    for(int i = 1; i < n; ++i){
        cin >> b;
        if(b == 1){
            v.push_back(a);
            nr_etaje++;
        }
        a = b;
    }

    v.push_back(a);
    nr_etaje += 1;

    cout << nr_etaje << endl;
    for(auto it : v){
        cout << it << ' ';
    }

}


#include<bits/stdc++.h>
using namespace std;
int main()
{
	string q;
	int n,c=0,y=1,x;
	scanf("%d",&n);
	while(n--&&scanf("%d",&x))
	{
		if(x==y)
		{
			y++;
			continue;
		}
		q+=(y-1+'0');
		y=2;c++;
	}
	printf("%d\n",c+1);
	int now=0;
	while(q.length()!=now)
	cout<<(int)(q[now++]-'0')<<" ";
	cout<<y-1<<endl;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
	string q;
	int n,c=0,y=1,x;
	scanf("%d",&n);
	while(n--&&scanf("%d",&x))
	{
		if(x==y)
		{
			y++;
			continue;
		}
		q+=(y-1+'0');
		y=2;c++;
	}
	printf("%d\n",c+1);
	int now=0;
	while(q.length()!=now)
	cout<<q[now++]<<" ";
	cout<<y-1<<endl;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
	int q[20000001]={0};
	int n,c=0,y=1,x;
	scanf("%d",&n);
	while(n--&&scanf("%d",&x))
	{
		if(x==y)
		{
			y++;
			continue;
		}
		q[c]=y-1;
		y=2;c++;
	}
	printf("%d\n",c+1);
	int now=0;
	c--;
	while(now<=c)
	cout<<q[now++]<<" ";
	cout<<y-1<<endl;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
	int q[20000001]={0};
	int n,c=0,y=1,x;
	scanf("%d",&n);
	while(n--&&scanf("%d",&x))
	{
		if(x==y)
		{
			y++;
			continue;
		}
		q[c]=y-1;
		y=2;c++;
	}
	printf("%d\n",c+1);
	int now=0;
	while(now<=c)
	cout<<q[now++]<<" ";
	cout<<y-1<<endl;
}


#define _CRT_SBCVRE_NO_ DEPRECATE
#include<set>
#include<cmath>
#include<queue>
#include<stack>
#include<vector>
#include<string>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<functional>
typedef unsigned long long ll;
using namespace std;

const int MAXN = 1001;
const int INF = 0x3f3f3f;

int arr[MAXN];
int temp[MAXN];
int num;
int main()

{
	int n,step=0;
	cin >> n;
	if(n<=1000 && n>=1)
		for(int i=1; i<=n; i++)
		{
			cin >> 	arr[i];
		}
		for(int i=1; i<=n; i++)
		{
			if(arr[i] == 1)
			{
				step++;
				num = 1;
			}
			if(arr[i+1] == 1 || arr[i+1] == 0)
			{
				temp[i] = num;
			}

			num++;
		}
		cout << step << endl;
		for(int i=1; i<=n; i++)
		{
			if(temp[i] != 0)
				cout << temp[i] << " ";
		}

	return 0;

}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
	int n,a[1005],ans=0;
	scanf("%d",&n);
	int x,y;
	for (int i=1;i<=n;i++) {
		cin>>x;
		if (x==1 && i!=1) a[++ans]=y;
		y=x;
	}
	a[++ans]=y;
	cout<<ans<<endl;
	cout<<a[1];
	for (int i=2;i<=ans;i++)
		cout<<' '<<a[i];
	cout<<endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int n,ans,a[1005];
int main(){
    cin>>n;
    for (int i=1;i<=n;i++){
        cin>>a[i];
        if (a[i]==1) ans++;
    }
    cout<<ans<<endl;
    for (int i=1;i<=n;i++)
        if (a[i]==1){
            int sum=1;
            for (int j=i;j<=n&&a[j]<a[j+1];j++)
                sum++;
            cout<<sum<<" ";
        }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int n,judge=0,sum=0,ans[1010],a;
int main(){
    cin>>n;
    for(int i=1;i<=n;++i){
        cin>>a;
        if(a==1){
            sum++;
            if(i!=1){
                ans[sum]=judge+1;
                judge=0;
            }
        }
        else
            judge++;
    }
    cout<<sum<<endl;
    for(int i=2;i<=sum;++i)cout<<ans[i]<<" ";
    cout<<judge+1;
}


#include<bits/stdc++.h>
int main(){
	int n,m=0;
	int a[1001];
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
    {
	std::cin>>a[i];
	if(a[i]==1)
	m++;
	}
	std::cout<<m<<"\n";
	for(int i=1;i<n;i++)
	if(a[i+1]==1) std::cout<<a[i]<<" ";
	std::cout<<a[n];
	return 0;
}


#include<cstdio>
#include<iostream>
using namespace std;
int n,a[1005],b[1005],m;
int main(){
	cin>>n;
	for(int i=1;i<=n;i++)cin>>a[i];
	for(int i=1;i<=n;){
		m++;
		b[m]=1;
		i++;
		while(a[i]==a[i-1]+1){
			b[m]++;
			i++;
		}
	}
	cout<<m<<endl;
	for(int i=1;i<=m;i++){
		cout<<b[i]<<' ';
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int m,inn;
    cin>>m;
    int countx=0;
    int b[1005];
    for(int i=1;i<=m;i++)
    {
        cin>>inn;
        if(inn==1)
        {
            countx++;
            b[countx]=1;
        }
        else
            b[countx]++;
    }
    cout<<countx<<endl;
    for(int i=1;i<=countx;i++)
        cout<<b[i]<<" ";
    cout<<endl;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
 int n;
 scanf("%d",&n);
 int a[n],sum=0;
 for(int i=0;i<n;i++){
  scanf("%d",&a[i]);
  if(a[i]==1)sum++;
 }
 printf("%d\n",sum);
 for(int i=0;i<n;i++){
  if(a[i]==1){if(i!=0)printf("%d ",a[i-1]);}
 }
 printf("%d",a[n-1]);
}


#include<iostream>
using namespace std;//
int main()
{
    int n;
    cin>>n;
    int a[n],b[n],ind=0,m=1;
    for(int i=0;i++)
    {
        cin>>a[i];
    }
    int ans=0;
    for(int i=1;i<n;i++)
    {
        if(a[i]<=a[i-1])
        {
            b[ind]=m;
            m=0,ind++;
            ans++;
        }
    }
    cout<<ans;
    for(int i=0;i<ind;i++)
    cout<<b[i]<<endl;
    return 0;
}


#include<iostream>
using namespace std;//
int main()
{
    int n;
    cin>>n;
    int a[n],b[n],ind=0,m=1;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    int ans=0;
    for(int i=1;i<n;i++)
    {
        if(a[i]<=a[i-1])
        {
            b[ind]=m;
            m=0,ind++;
            ans++;
        }
    }
    cout<<ans;
    for(int i=0;i<ind;i++)
    cout<<b[i]<<endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int n,ans,a[1001];
int main(){
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a;
        cd++;
        if(a==1){
            a[ans]=cd;
            ans++;
            cd=0;
        }
    }
    cout<<ans<<endl;
    for(int i=1;i<=ans;i++){
        cout<<a[i]<<" ";
    }
    return 0;
}


#include<bits/stdc++.h>

using namespace std;
int n,a[10005],sum=0;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
	}
	for(int i=1;i<=n;i++)
	{
		if(a[i]==1) sum++;
	}
	cout<<sum<<endl;
	for(int i=1;i<n;i++)
	{
		if(a[i+1]==1) cout<<a[i]<<" ";
	}
	cout<<a[n];

	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,a[1001],b[1001],ans=0,k=0;
	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	for(int i=1;i<=n;i++)
	{
		if(a[i+1]>a[i])
		{
			ans++;
			continue;
		}
		else
		{
			k++;
			b[k]=ans+1;
			ans=0;
		}
	}
	cout<<k<<endl;
	for(int i=1;i<=k;i++)
		cout<<b[i]<<" ";
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int a,b,c,d[1001],e;
int main()
{
	cin>>a;
	for(;c<a;c++)
	{
		cin>>b;
		(b==1)?d[e++]=c++:c++;
	}
	cout<<e;
	for(c=0;c<e;)
	{
		cout<<d[c++]<<" ";
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a=1,n,ans[1000],FUCK=1,x;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>x;
		if(x==a) a++;
		else
		{
			ans[FUCK]=a;
			a=1;
			FUCK++;
		}
	}
	ans[FUCK]=a;
	for(int i=1;i<=FUCK;i++) cout<<i<<endl;
}


#include<bits/stdc++.h>
using namespace std;
int n;
int a[10005];
int countx=1;
int main(){

	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	for(int i=2;i<=n;i++)
	{
		if(a[i]==a[i-1]+1)
			countx++;
		else if(a[i]!=a[i-1]+1)
		{
			cout<<countx<<" ";
			countx=1;
		}
	}
	cout<<countx<<endl;
}


#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
using namespace std;
int n,a[10005];
int ans,t[10005];
int main(){
	cin>>n;
	for (int i=1;i<=n;i++)
	cin>>a[i];
	for (int i=2;i<=n;i++){
		if (a[i]==1) ans++,t[ans]=a[i-1];
	}
	ans++;t[ans]=a[n];
	cout<<ans<<endl;
	for (int i=1;i<=ans;i++)
	cout<<t[i]<<" ";
	//system("pause");
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int n,m,p[1010],a;
int main ()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a);
		if(a==1)
		m++;
		p[m]=a;
		cout<<m<<" ";
	}
	printf("%d\n",m);
	for(int i=1;i<=m;i++)
		printf("%d ",p[i]);
	return 0;
}


#include<iostream>
using namespace std;
int main() {
    int c, x, g = 0, l = 0, m[100], q = 0;
    cin >> c;
    for (int i = 0; i < c; i++) {
        cin >> x;
        if (x == 1 && g != 0) m[q++] = l;
        if (x == 1) g++;
        l = x;
    }
    cout << g << endl;
    for (int i = 0; i < q; i++) cout << m[i] << " ";
    cout << l << endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,a[1001],ans=0;
	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	for(int i=1;i<=n;i++)
	{
		if(a[i+1]>a[i])
		{
			ans++;
			continue;
		}
		else
		{
			cout<<ans+1<<" ";
			ans=0;
		}
	}
	cout<<ans<<endl;
	return 0;
}


#include <cstdio>
#include <iostream>
using namespace std;

int n,a[1100],ans=1,cnt[1010];

int main()
{
  	scanf("%d",&n);
  	for(int i=1;i<=n;++i) scanf("%d",&a[i]);
  	for(int i=1;i<=n;++i)
  	{
  		if(a[i]>a[i-1])
  			cnt[ans]++;
  		else cnt[++ans]++;
	}
	printf("%d\n",ans);
	for(int i=1;i<=ans;++i) printf("%d ",cnt[i]);
    return 0;
}


#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<iostream>
#include<algorithm>
using namespace std;
int n,p;
int a[1010],top=0,cnt=1;
int main()
{
	cin>>n>>p;
	for (int i=1;i<n;i++)
	{
		int x;
		cin>>x;
		if (x==p+1)
		{
			cnt++;
			p++;
		}
		else
		{
			a[top++]=cnt;
			p=x;
			cnt=1;
		}
	}
	a[top++]=cnt;
	cout<<top<<"\n";
	for (int i=0;i<top;++i)
	{
		cout<<a[i]<<" ";
	}
	cout<<"\n";
}


#include<cstdio>
using namespace std;
int n,a,k,cnt,tot,l[1010];
int main()
{
  scanf("%d",&n);
  for(int i=1;i<=n;i++)
  {
  	scanf("%d",&a);
	if(a<=k)  l[++tot]=cnt,cnt=0;
  	cnt++,k=a;
  }
  l[++tot]=cnt;
  printf("%d\n",tot);
  for(int i=1;i<=tot;i++)
    printf("%d ",l[i]);
  return 0;
}


#include<iostream>
using namespace std;//
int main()
{
    int n;
    cin>>n;
    int a[n],b[n],ind=0,m=1;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    int ans=0;
    for(int i=1;i<n;i++)
    {
        if(a[i]<=a[i-1])
        {
            b[ind]=m;
            m=0,ind++;
            ans++;
        }
        m++;
    }
    b[ind]=m;
    ind++;
    cout<<ans<<endl;
    for(int i=0;i<ind;i++)
    cout<<b[i]<<" ";
    return 0;
}


#include <iostream>
using namespace std;
int main(){
    int a[1001],n,sum=0;
    cin>>n;
    for(int i=1;i<=n;i++) cin>>a[i];
    for(int i=1;i<=n;i++)
        if(a[i]==1) sum++;
    cout<<sum<<endl;
    for(int i=1;i<n;i++)
        if(a[i+1]==1) cout<<a[i]<<" ";
    cout<<a[n]<<endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int a,b,c,d[1001],e,f;
int main()
{
	cin>>a;
	for(;c<a;c++)
	{
		cin>>b;
		if(b==1)
		{
			d[e++]=f;
			f=0;
		}
		f++;
	}
	cout<<e;
	for(c=0;c<e;)
	{
		cout<<d[c++]<<" ";
	}
	return 0;
}


#include <iostream>
using namespace std;
int main(){
    int a[1001],n,sum=0;
    cin>>n;
    for(int i=1;i<=n;i++) cin>>a[i];
    for(int i=1;i<=n;i++)
        if(a[i]==1) sum++;
    cout<<sum<<endl;
    for(int i=1;i<n;i++)
        if(a[i+1]==1) cout<<a[i]<<" ";
    cout<<a[n]<<endl;
}


#include<bits/stdc++.h>
using namespace std;

int n;
vector<int> num;

int main()
{
	cin >> n;
	int x, cnt = 0;
	for (int i = 1; i <= n; i++)
	{
		cin >> x;
		if (x == 1)
		{
			num.push_back(cnt);
			cnt = 0;
		}

		cnt++;
	}
	num.push_back(cnt);

	cout << num.size() - 1 << '\n';
	for (int i = 1; i < num.size(); i++)
	{
		if (i != 1) cout << ' ';
		cout << num[i];
	}
	cout << '\n';

	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int n,m,p[1010],a;
int main ()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a);
		if(a==1)
		m++;
		p[m]=a;
	}
	printf("%d\n",m);
	for(int i=1;i<=m;i++)
		printf("%d ",p[m]);
	return 0;
}


#include<iostream>
#include<fstream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>

using namespace std;
long long n,h,b;
int a[1000+10];
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		if(a[i]==1)
		h++;
	}
	a[n+1]=1;
	cout<<h<<endl;
	b=1;
	for(int i=2;i<=n+1;i++)
	{
		if(a[i]==1)
		{
			cout<<i-b<<' ';
			b=i;
		}
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int L = 1 << 20;
char buffer[L],*S,*T;
#define getchar() (S == T && (T = (S = buffer) + fread(buffer,1,L,stdin),S == T) ? EOF : *S++)
inline int read(){
	int s = 0,f = 1;
	char ch = getchar();
	while(!isdigit(ch)){
		if(ch == '-')f = -1;
		ch = getchar();
	}
	while(isdigit(ch)){
		s = s *10 + ch - '0';
		ch = getchar();
	}
	return s * f;
}
const int maxn = 1e5+10;
int jl[maxn];
int cnt;
int main(){
	int n = read();
	for(int i = 1;i <= n;++i){
		int x = read();
		if(x == 1){
			jl[++cnt] = i;
		}
	}
	jl[++cnt] = n + 1;
	printf("%d\n",cnt - 1);
	for(int i = 2;i <= cnt;++i){
		printf("%d ",jl[i] - jl[i-1]);
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int n,ans,a[1001],cd;
int main(){
    cin>>n;
    for(int i=1;i<=n;i++){
        int x;
        cin>>x;
        cd++;
        if(x==1){
            a[ans]=cd;
            ans++;
            cd=0;
        }
    }
    cout<<ans<<endl;
    for(int i=1;i<=ans;i++){
        cout<<a[i]<<" ";
    }
    return 0;
}


#include <algorithm>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>

#ifdef PRINTERS
#include "printers.hpp"
using namespace printers;
#define tr(a)		cerr<<#a<<": "<<a<<endl;
#else
#define tr(a)
#endif

#define ll          long long
#define pb          push_back
#define mp          make_pair
#define pii         pair<int,int>
#define vi          vector<int>
#define all(a)      ((a).begin(),(a).end())
#define F           first
#define S           second
#define sz(x)       (int)x.size()
#define hell        1000000007
#define endl        '\n'
#define rep(i,a,b)	for(int i=a;i<b;i++)
using namespace std;
int cnt[100001];
void solve(){
    int n,h;
    cin>>n>>h;
    long double ans=h/sqrt(n);
    rep(i,0,n-1)
    {
        printf("%.12lf ",ans);
        ans=ans*sqrt(2);
    }
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t=1;
//	cin>>t;
	while(t--){
		solve();
	}
	return 0;
}


#include <algorithm>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>

#ifdef PRINTERS
#include "printers.hpp"
using namespace printers;
#define tr(a)		cerr<<#a<<": "<<a<<endl;
#else
#define tr(a)
#endif

#define ll          long long
#define pb          push_back
#define mp          make_pair
#define pii         pair<int,int>
#define vi          vector<int>
#define all(a)      ((a).begin(),(a).end())
#define F           first
#define S           second
#define sz(x)       (int)x.size()
#define hell        1000000007
#define endl        '\n'
#define rep(i,a,b)	for(int i=a;i<b;i++)
using namespace std;
int cnt[100001];
void solve(){
    long double n,h;
    cin>>n>>h;
    float ans=(float)h/(float)sqrt(n);
    int k=2;
    rep(i,0,n-1)
    {
        cout<<setprecision(12)<<ans<<' ';
        ans=ans*((float)sqrt(k));
    }
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t=1;
//	cin>>t;
	while(t--){
		solve();
	}
	return 0;
}


#include <algorithm>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>

#ifdef PRINTERS
#include "printers.hpp"
using namespace printers;
#define tr(a)		cerr<<#a<<": "<<a<<endl;
#else
#define tr(a)
#endif

#define ll          long long
#define pb          push_back
#define mp          make_pair
#define pii         pair<int,int>
#define vi          vector<int>
#define all(a)      ((a).begin(),(a).end())
#define F           first
#define S           second
#define sz(x)       (int)x.size()
#define hell        1000000007
#define endl        '\n'
#define rep(i,a,b)	for(int i=a;i<b;i++)
using namespace std;
int cnt[100001];
void solve(){
    long double n,h;
    cin>>n>>h;
    float ans=(float)h/(float)sqrt(n);
    int k=1;
    rep(i,0,n-1)
    {
        cout<<setprecision(12)<<ans*((float)sqrt(k))<<' ';
        k++;
    }
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t=1;
//	cin>>t;
	while(t--){
		solve();
	}
	return 0;
}


#include <algorithm>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>

#ifdef PRINTERS
#include "printers.hpp"
using namespace printers;
#define tr(a)		cerr<<#a<<": "<<a<<endl;
#else
#define tr(a)
#endif

#define ll          long long
#define pb          push_back
#define mp          make_pair
#define pii         pair<int,int>
#define vi          vector<int>
#define all(a)      ((a).begin(),(a).end())
#define F           first
#define S           second
#define sz(x)       (int)x.size()
#define hell        1000000007
#define endl        '\n'
#define rep(i,a,b)	for(int i=a;i<b;i++)
using namespace std;
int cnt[100001];
void solve(){
    long double n,h;
    cin>>n>>h;
    float ans=(float)h/(float)sqrt(n);
    int k=2;
    rep(i,0,n-1)
    {
        cout<<setprecision(12)<<ans<<' ';
        ans=ans*((float)sqrt(k));
        k++;
    }
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t=1;
//	cin>>t;
	while(t--){
		solve();
	}
	return 0;
}


#include <algorithm>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>

#ifdef PRINTERS
#include "printers.hpp"
using namespace printers;
#define tr(a)		cerr<<#a<<": "<<a<<endl;
#else
#define tr(a)
#endif

#define ll          long long
#define pb          push_back
#define mp          make_pair
#define pii         pair<int,int>
#define vi          vector<int>
#define all(a)      ((a).begin(),(a).end())
#define F           first
#define S           second
#define sz(x)       (int)x.size()
#define hell        1000000007
#define endl        '\n'
#define rep(i,a,b)	for(int i=a;i<b;i++)
using namespace std;
int cnt[100001];
void solve(){
    long double n,h;
    cin>>n>>h;
    float ans=(float)h/(float)sqrt(n);
    rep(i,0,n-1)
    {
        cout<<setprecision(9)<<ans<<' ';
        ans=ans*1.4142135623;
    }
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t=1;
//	cin>>t;
	while(t--){
		solve();
	}
	return 0;
}