n = int(input()) coordinate = [ int(v) for v in input().split() ][::-1] for i in range(n-2): coordinate[i+2] += coordinate[i] coordinate[i] = 0 zero = 0 for i in range(n): if coordinate[i] == 0: zero += 1 else: break coordinate = [ str(i) for i in coordinate ] s = " ".join(coordinate[zero:][::-1]) print(len(coordinate[zero:])-1) print(s)