// {{{ Templates #include #define show(x) cerr << #x << " = " << x << endl using namespace std; using ll = long long; using pii = pair; using vi = vector; template ostream& operator<<(ostream& os, const vector& v) { os << "sz:" << v.size() << "\n["; for (const auto& p : v) { os << p << ","; } os << "]\n"; return os; } template ostream& operator<<(ostream& os, const pair& p) { os << "(" << p.first << "," << p.second << ")"; return os; } constexpr ll MOD = (ll)1e9 + 7LL; template constexpr T INF = numeric_limits::max() / 100; // }}} int main() { cin.tie(0); ios::sync_with_stdio(false); int n; cin >> n; vector b(n); for (int i = 0; i < n; i++) { cin >> b[i]; } vector plus(n + 1); for (int i = 0; i <= n; i++) { plus[i] = (i % 4 == 0 or i % 4 == 3); } vector offset(n + 1); offset[0] = 0; for (int i = 1; i <= n; i++) { offset[i] = (i % 2 == 0) ? offset[i - 1] : -offset[i - 1]; offset[i] += (i % 2 == 0) ? -b[i - 1] : b[i - 1]; } constexpr ll MAX = (ll)1e18; ll lower = 1; ll upper = MAX; for (int i = 0; i <= n; i++) { if (plus[i]) { lower = max(lower, 1 - offset[i]); upper = min(upper, MAX - offset[i]); } else { lower = max(lower, offset[i] - MAX); upper = min(upper, offset[i] - 1); } } if (lower > upper) { cout << -1 << endl; } else { cout << n + 1 << endl; const ll a0 = lower; for (int i = 0; i <= n; i++) { cout << offset[i] + (plus[i] ? a0 : -a0) << endl; } } return 0; }