using System; using System.Linq; internal class Program { public static void Main(string[] args) { var d = int.Parse(Console.ReadLine()); var nums = Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); for (int i = d; i >= 3; i--) { nums[i - 2] += nums[i]; nums[i] = 0; } int modD = 0; for (int i = 2; i >= 0; i--) { if (nums[i] != 0) { modD = i; break; } } Console.WriteLine(modD); for (int i = 0; i < modD; i++) { Console.Write(nums[i] + " "); } Console.WriteLine(nums[modD]); } }