#include <fstream>
#include <cmath>

using namespace std;

int main()
{
	ifstream f1("DAYCONDN.INP");
   long long n,a[100000],num=0,num2=0,local1,ans;
   f1>>n;
   for (long long i=0;i<n;i++){f1>>a[i];}
   f1.close();
   ofstream f2("DAYCONDN.OUT");
   local1=n-1,ans=local1;
   for (long long k=n-1;k>=0;k--){

    if (a[k]>0){num++;}
    if (num>num2){num2=num;ans=local1;}
    if (a[k]<=0){num=0;
	if(a[k-1]>0){local1=k-1;
	}}

   }
   f2<<num2<<endl;
   for (long long z=ans-num2+1;z<=ans;z++){f2<<a[z]<<" ";
   }
}
