#include "bits/stdc++.h" using namespace std; #define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i)) #define rep(i,j) FOR(i,0,j) #define each(x,y) for(auto &(x):(y)) #define mp make_pair #define mt make_tuple #define all(x) (x).begin(),(x).end() #define debug(x) cout<<#x<<": "<<(x)< pii; typedef vector vi; typedef vector vll; ll MA = (ll)1e18; ll a[100001]; int f(vll &b, ll x) { int res = 0; a[0] = x; for(int i = 1; i <= sz(b); ++i) { if(i & 1) { x = b[i - 1] - a[i - 1]; } else { x = a[i - 1] - b[i - 1]; } int k = (i - 1) / 2; if(k & 1) { if(x > MA)res |= 1; if(x < 1)res |= 2; } else { if(x < 1)res |= 1; if(x > MA)res |= 2; } a[i] = x; } return res; } int main(){ ios::sync_with_stdio(false); cin.tie(0); int n; while(cin >> n) { vll b(n); rep(i, n)cin >> b[i]; if((f(b, 1) & 1) || (f(b, MA) & 2)) { cout << -1 << endl; continue; } ll lb = 1, ub = MA, m; // [l,R] ll L = 1, R = MA; if(f(b, MA) & 1) { // [lb, ub) while(ub - lb > 1) { m = (ub + lb) / 2; ((f(b, m) & 1) ? ub : lb) = m; } R = lb; } if(f(b, R) & 2) { cout << -1 << endl; } else { cout << n + 1 << endl; rep(i, n + 1) { cout << a[i] << endl; } } } }