D = int(input()) coeff = list(map(int, input().split())) b0 = 0 b1 = 0 b2 = 0 for i in range(D + 1): a_i = coeff[i] if i == 0: b0 += a_i elif i == 1: b1 += a_i elif i == 2: b2 += a_i else: if i % 2 == 1: # 1 -> x^1 b1 += a_i else: # 0 -> x^2 b2 += a_i # Determine the maximum degree max_deg = 0 coefficients = [] if b2 != 0: max_deg = 2 coefficients = [b0, b1, b2] elif b1 != 0: max_deg = 1 coefficients = [b0, b1] else: # Check if all are zero if b0 == 0: max_deg = 0 coefficients = [0] else: max_deg = 0 coefficients = [b0] # Truncate coefficients list based on max_deg if max_deg == 2: coefficients = coefficients[:3] # [b0, b1, b2] elif max_deg == 1: coefficients = coefficients[:2] # [b0, b1] else: coefficients = coefficients[:1] # [b0] # Now, check trailing zeros for higher degrees # For example, if max_deg is 1 but b1 is zero due to previous steps # But since max_deg is determined by checking non-zero, this should be handled # Now handle the case where all are zero (but earlier handled by b0=0 -> coefficients [0]) # Now, output print(max_deg) print(' '.join(map(str, coefficients)))