import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int D = sc.nextInt(); int [] a = new int [D+1]; for(int i=0; i<=D; i++){ a[i] = sc.nextInt(); } for(int i=D; i>=3; i--){ a[i-2]+=a[i]; a[i]=0; } int c=0; for(int i=D-3; i>=0; i--){ if(a[i]!=0){ c=i; break; } } System.out.println(c); for(int i=0; i<=c; i++){ System.out.print(a[i]); if(i!=c){System.out.print(" ");} } System.out.println(); } }