D = int(input()) A = list(map(int,input().split())) B = [1,0,-1,0] if D<3: print(D) print(*A) else: A = A[::-1] for i in range(D-4+2): a = A[i] for j in range(4): A[i+j] -= a*B[j] ind = -1 for i in range(D+1): if A[i]!=0: ind = i break if ind==-1: print(0) print(0) else: print(D-ind) print(*A[ind:][::-1])