D = input() a = map(int,raw_input().split()) for i in xrange(D,2,-1): a[i-2] += a[i] a[i] = 0 D2 = 0 for i in xrange(min(3,D+1)): if a[i] != 0: D2 = i print D2 print " ".join(str(a[i]) for i in xrange(D2+1))