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 = -Long.MAX_VALUE; long oddMin = Long.MAX_VALUE; long evenMax = -Long.MAX_VALUE; long evenMin = Long.MAX_VALUE; for (int i = 1; i <= n + 1; ++i) { if (i % 2 == 1) { oddMax = Math.max(oddMax, a[i]); oddMin = Math.min(oddMin, a[i]); } else { evenMax = Math.max(evenMax, a[i]); evenMin = Math.min(evenMin, a[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); for (int i = 1; i <= n + 1; ++i) { if (i % 2 == 1) { System.out.println(a[i] + add); } else { System.out.println(a[i] - add); } } for (int i = 1; i <= n; ++i) { if (i % 2 == 0) { assert b[i] == a[i] - a[i + 1]; } else { assert b[i] == a[i] - a[i + 1]; } } return; } } System.out.println(-1); } static void tr(Object... objects) { System.out.println(Arrays.deepToString(objects)); } }