D = int(input()) a = list(map(int, input().split())) for i in range(D, 2, -1): a[i - 2] += a[i] ans = 0 if a[2]: ans = 2 elif a[1]: ans = 1 print(ans) for i in range(ans + 1): if ans == i: print(a[i]) else: print(a[i], end=' ')