D = int(input()) A = list(map(int, input().split())) for i in range(D, 2, -1): A[i - 2] += A[i] A[i] = 0 Dd = 2 while not A[Dd] and Dd > 0: Dd -= 1 print(Dd) print(*A[:Dd + 1])