#include <iostream>
#include <fstream>
#include <cmath>
using namespace std;
int main()
{
    ifstream fi("daycondn.inp");
    int64_t n;
    fi>>n;
    int64_t a[n],tt[n];
    for(int64_t i=1;i<=n;i++)
    {
        fi>>a[i];
        tt[i]=1;
    }
    fi.close();
    ofstream fo("daycondn.out");
    int64_t mx=0;
    for (int64_t i=1;i<=n;i++)
        if(a[i]>0 && a[i+1]>0)
        {
            tt[i+1]=tt[i]+1;
            if(tt[i+1]>mx)
            {
                mx=tt[i+1];
            }
        }
    int64_t d,c;
    for(int64_t i=1;i<=n;i++)
        if(tt[i]==mx)
        {
            c=i;
            d=i-mx+1;
            break;
        }
    fo<<mx<<endl;
    for(int64_t i=d;i<=c;i++)
        fo<<a[i]<<' ';
    fo.close();
    return 0;
}
