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