#include #include #include using namespace std; using ll = long long; const ll INF = 1e18 + 100; const int MAX_N = 1e5; const ll MAX_A = 1e18; const ll MIN_A = 1; int n; ll b[MAX_N + 1]; // return a_1 ll solve() { if (n == 1 && b[1] == 1) return -1; ll a_min = -INF; ll a_max = INF; for (int i = n; i >= 1; --i) { if (i % 2 == 1) { ll a_min_ = b[i] - a_max; ll a_max_ = b[i] - a_min; a_min = max(MIN_A, a_min_); a_max = min(MAX_A, a_max_); } else { a_min = max(MIN_A, b[i] + a_min); a_max = min(MAX_A, b[i] + a_max); } if (a_min > a_max) return -1; } return a_min; } void output(ll a_1) { ll a = a_1; cout << n + 1 << endl; cout << a << endl; for (int i = 1; i <= n; ++i) { if (i % 2 == 1) { a = b[i] - a; assert(a >= MIN_A && a <= MAX_A); cout << a << endl; } else { a = a - b[i]; assert(a >= MIN_A && a <= MAX_A); cout << a << endl; } } } int main() { cin >> n; for (int i = 1; i <= n; ++i) cin >> b[i]; ll a_1 = solve(); if (a_1 != -1) output(a_1); else cout << -1 << endl; return 0; }