package no040; import java.util.Scanner; 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=0;i<=d-3;i++) { a[d-i-2] += a[d-i]; a[d-i] = 0; } int d_ = 0; for(int i=0;i<=d;i++) { if (a[i] > 0) { d_ = i; } } System.out.println(d_); StringBuilder sb = new StringBuilder(); for(int i=0;i<=d_;i++) { if (i > 0) { sb.append(' '); } sb.append(a[i]); } System.out.println(sb.toString()); } }