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