#include #include #include #include #include using namespace std; typedef long long LL; int main(int argc, char *argv[]) { LL N, a[100001], b[100000], low = 1, high = 1000000000000000000; cin >> N; bool valid = true; for (int i = 0; i != N; ++i) { cin >> b[i]; if (i % 2) { low = max(low, b[i] + 1); if (low > high) { valid = false; } LL next_low = max(1LL, low - b[i]); LL next_high = high - b[i]; low = next_low; high = next_high; if (low > high) { valid = false; } } else { LL next_low = max(1LL, b[i] - high); LL next_high = b[i] - low; low = next_low; high = next_high; if (low > high) { valid = false; } } } if (!valid) { cout << -1 << endl; } else { a[N] = low; for (int i = N - 1; i >= 0; --i) { if (i % 2) { low += b[i]; } else { low = b[i] - low; } a[i] = low; } cout << (N + 1) << endl; for (int i = 0; i <= N; ++i) { cout << a[i] << endl; } } return 0; }