import java.util.Arrays; import java.util.Scanner; public class Main { static int max; public static void main (String[] args) { Scanner sc = new Scanner(System.in); max = sc.nextInt(); int[] nums = new int[max + 1]; for (int i = 0; i <= max; i++) nums[i] = sc.nextInt(); System.out.println(Arrays.toString(nums)); int next = -1; for (int i = 0; i <= max; i++) { if (nums[i] != 0) { next = max - i; break; } } solve(next, nums); sc.close(); } public static void solve (int d, int[] nums) { if (d < 3) { System.out.print(d + "\n" + nums[max - d]); for (int i = max - d + 1; i <= max; i++) System.out.print(" " + nums[i]); return; } int i = 0; for (; i <= max; i++) { if (nums[i] != 0) { nums[i + 2] += nums[i]; nums[i] = 0; break; } } int next = -1; for (int j = 0; j <= max; j++) { if (j == i || j == i + 2) continue; if (next == -1 && nums[j] != 0) next = max - j; } //System.out.println(Arrays.toString(nums)); solve(next, nums); } }