n = int(input()) b = [0] + [int(input()) for _ in range(n)] # i is odd # b(i) = a(i) + a(i + 1) # b(i + 1) = a(i + 1) - a(i + 2) # -> a(i + 1) = b(i + 1) + a(i + 2) # b(i) = a(i) + (b(i + 1) + a(i + 2)) # -> a(i + 2) = b(i) - b(i + 1) - a(i) # i -> i - 2 # a(i) = b(i - 2) - b(i - 1) - a(i - 2) # apply # a(3) = b(1) - b(2) - a(1) > 0 # -> a(1) < b(1) - b(2) = G_odd(3) # a(5) = b(3) - b(4) - a(3) # = b(3) - b(4) - (b(1) - b(2) - a(1)) # = b(3) - b(4) - b(1) + b(2) + a(1) > 0 # -> L_odd(5) = b(1) - b(2) - b(3) + b(4) < a(1) # a(7) = b(5) - b(6) - a(5) # = b(5) - b(6) - (b(3) - b(4) - b(1) + b(2) + a(1)) # = b(5) - b(6) - b(3) + b(4) + b(1) - b(2) - a(1) > 0 # -> a(1) < b(1) - (2) - b(3) + b(4) + b(5) - b(6) = G_odd(7) # repeat then ... max(L_odd) < a(1) < min(G_odd) # if min(G_odd) - max(L_odd) > 1, a(1) is exist, otherwise not # j is even # b(j) = a(j) - a(j + 1) # b(j + 1) = a(j + 1) + a(j + 2) # -> a(j + 1) = b(j + 1) - a(j + 2) # b(j) = a(j) - (b(j + 1) - a(j + 2)) # -> a(j + 2) = b(j) + b(j + 1) - a(j) # j -> j - 2 # a(j) = b(j - 2) + b(j - 1) - a(j - 2) # apply # a(4) = b(2) + b(3) - a(2) > 0 # -> a(2) < b(2) + b(3) = G_even(4) # a(6) = b(4) + b(5) - a(4) # = b(4) + b(5) - (b(2) + b(3) - a(2)) # = b(4) + b(5) - b(2) - b(3) + a(2) > 0 # -> L_even(6) = b(2) + b(3) - b(4) - b(5) < a(2) # repeat then ... max(L_even) < a(2) < min(G_odd) # if min(G_even) - max(L_even) > 1, a(2) is exist, otherwise not L_odd = 0 G_odd = 10 ** 18 + 1 tmp = 0 for i in range(3, n + 1, 2): tmp = b[i - 2] - b[i - 1] - tmp if ((i - 3) // 2) % 2 == 0: G_odd = min(G_odd, tmp) else: L_odd = max(L_odd, -tmp) L_even = 0 G_even = 10 ** 18 + 1 tmp = 0 for j in range(4, n + 1, 2): tmp = b[j - 2] + b[j - 1] - tmp if ((j - 4) // 2) % 2 == 0: G_even = min(G_even, tmp) else: L_even = max(L_even, -tmp) print(L_odd, G_odd, L_even, G_even) a1 = L_odd + 1 a2 = L_even + 1 if a1 < G_odd and a2 < G_even and min(b[1::2]) > 1: a = [0, a1, a2] for k in range(3, n + 2): if k % 2 == 0: a.append(b[k - 2] + b[k - 1] - a[k - 2]) else: a.append(b[k - 2] - b[k - 1] - a[k - 2]) print(n + 1, *a[1:], sep='\n') else: print(-1)