#!/usr/bin/env python3 #fileencoding: utf-8 D = int(input()) a = [int(i) for i in input().strip().split(" ")] a.reverse() for i in range(D-2): a[i+2] += a[i] a[i] = 0 a.reverse() D = 0 for i in range(len(a)): if a[i] != 0: D = i print(D) for i in range(D+1): print(a[i], end=" ") print()