package yukicoder; import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); long[] b = new long[n + 1]; for (int i = 0; i < n; ++i) { b[i + 1] = sc.nextLong(); } /* * a_0-a_1=b_1 a_1+a_2=b_2 a_2-a_3=b_3 a_3+a_4=b_4 * * a_0=0 * * a_(i+1)=b_i-a_i a_(i+1)=a_i-b_i */ long[] a = new long[n + 2]; long min = 1; int counter = 0; while (true) { ++counter; a[1] = min; for (int i = 2; i <= n + 1; ++i) { if (i % 2 == 0) { a[i] = b[i - 1] - a[i - 1]; } else { a[i] = a[i - 1] - b[i - 1]; } min = Math.min(min, a[i]); } if (min > 0) break; if (min < 1) { min = 1 - min; } if (counter > 10) { System.out.println(-1); return; } } System.out.println(n + 1); for (int i = 1; i <= n + 1; ++i) { System.out.println(a[i]); } } static void tr(Object... objects) { System.out.println(Arrays.deepToString(objects)); } }