using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ProgrammingContest { class MainClass { Scanner sc; static void Main(string[] args) { new MainClass().Solve(); } void Solve() { #if DEBUG string backPath = ".."; char dirSep = System.IO.Path.DirectorySeparatorChar; string inFilePath = backPath + dirSep + backPath + dirSep + "in.txt"; sc = new Scanner(new System.IO.StreamReader(inFilePath)); #else sc = new Scanner(); #endif int D = sc.NextInt; int[] a = new int[D + 1].Select(val => sc.NextInt).ToArray(); Array.Reverse(a); for (int i = 0; i < D - 2; i++) { a[i + 2] += a[i]; } int dd = Math.Min(2, D); List ans = new List(); if (dd == 2 && a[D - 2] != 0) { for (int i = D - 2; i <= D; i++) { ans.Add(a[i]); } } else if (dd >= 1 && a[D - 1] != 0) { for (int i = D - 1; i <= D; i++) { ans.Add(a[i]); } } else { ans.Add(a[D]); } ans.Reverse(); Write(ans.Count - 1); Write(ArrayToString(ans.ToArray())); } string ArrayToString(T[] ar, string sep = " ") { return string.Join(sep, Array.ConvertAll(ar, el => el.ToString())); } void Write(object val) { Console.WriteLine(val.ToString()); } void Write(string format, params object[] vals) { Console.WriteLine(format, vals); } void fill(T[] ar, T val) { for (int i = 0; i < ar.Length; i++) { ar[i] = val; } } } class Scanner { Queue buffer; char[] sep; System.IO.TextReader reader; public Scanner(System.IO.TextReader reader = null) { this.buffer = new Queue(); this.sep = new char[] { ' ' }; this.reader = (reader ?? Console.In); } private void CheckBuffer() { if (this.buffer.Count == 0 && this.reader.Peek() >= 0) { string[] sreArray = this.reader.ReadLine().Split(this.sep); foreach (String elStr in sreArray) { this.buffer.Enqueue(elStr); } } } public String Next { get { this.CheckBuffer(); return this.buffer.Dequeue(); } } public int NextInt { get { return int.Parse(this.Next); } } public double NextDouble { get { return double.Parse(this.Next); } } public long NextLong { get { return long.Parse(this.Next); } } public bool IsEmpty { get { this.CheckBuffer(); return this.buffer.Count == 0; } } } }