#!/usr/bin/env python3 # %% import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines # %% N, *B = map(int, read().split()) # %% A0 = [0] * (N + 1) A1 = [1] + [0] * N for i, x in enumerate(B): if i % 2 == 0: A0[i + 1] = x - A0[i] A1[i + 1] = x - A1[i] else: A0[i + 1] = A0[i] - x A1[i + 1] = A1[i] - x # %% U = 10 ** 18 left = 1 right = U for x, y in zip(A0, A1): dx = y - x if dx == 1: L = 1 - x R = U - x else: L = x - U R = x - 1 if left < L: left = L if right > R: right = R # %% if left > right: print(-1) exit() # %% A = [0] * (N + 1) A[0] = left for i, x in enumerate(B): if i % 2 == 0: A[i + 1] = x - A[i] else: A[i + 1] = A[i] - x print(len(A)) print('\n'.join(map(str, A)))