package yukicoder; import java.util.*; public class Q451 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); long[] b = new long[n + 1]; long[] a = new long[n + 2]; long Max = 1_000_000_000_000_000_000L; for (int i = 1; i <= n; ++i) { b[i] = sc.nextLong(); if ((i + 1) % 2 == 0) a[i + 1] += b[i]; else a[i + 1] -= b[i]; } a[1] = 1; for (int i = 2; i <= n + 1; ++i) { if (i % 2 == 0) { a[i] -= a[i - 1]; } else { a[i] += a[i - 1]; } if (a[i] > 2 * Max || a[i] < -Max) { System.out.println(-1); return; } } long oddMax = a[1]; long oddMin = a[1]; long evenMax = a[2]; long evenMin = a[2]; for (int i = 4; i <= n + 1; i += 3) { oddMax = Math.max(oddMax, a[i]); oddMin = Math.min(oddMin, a[i]); if (i + 1 <= n + 1) { oddMax = Math.max(oddMax, a[i + 1]); oddMin = Math.min(oddMin, a[i + 1]); } ++i; } for (int i = 2; i <= n + 1; i += 3) { evenMax = Math.max(evenMax, a[i]); evenMin = Math.min(evenMin, a[i]); if (i + 1 <= n + 1) { evenMax = Math.max(evenMax, a[i + 1]); evenMin = Math.min(evenMin, a[i + 1]); } ++i; } ArrayDeque que = new ArrayDeque<>(); // oddにどれだけ加算するか que.add(Max - oddMax); que.add(-Max + evenMax); que.add(1 - oddMin); que.add(-1 + evenMin); while (!que.isEmpty()) { long add = que.poll(); if (oddMax + add <= Max && oddMax + add > 0 && evenMax - add <= Max && evenMax - add > 0 && oddMin + add > 0 && oddMin + add <= Max && evenMin - add > 0 && evenMin - add <= Max) { System.out.println(n + 1); a[1] += add; for (int i = 4; i <= n + 1; i += 3) { a[i] += add; if (i + 1 <= n + 1) a[i + 1] += add; ++i; } for (int i = 2; i <= n + 1; i += 3) { a[i] -= add; if (i + 1 <= n + 1) a[i + 1] -= add; ++i; } for (int i = 1; i <= n + 1; ++i) System.out.println(a[i]); return; } } System.out.println(-1); } static void tr(Object... objects) { System.out.println(Arrays.deepToString(objects)); } }