//初項a1における条件式を考えればよい。 #include #include #define int long long using namespace std; int n; int b[100000]; signed main() { int i; cin >> n; for (i = 0; i < n; i++) cin >> b[i]; int low = 1, high = 1000000000000000000; int val = 0; for (i = 0; i < n; i++) { if (i % 2 == 0) val = b[i] - val; else val = val - b[i]; if (i % 4 < 2) high = min(high, val - 1); else low = max(low, -val + 1); } if (low > high) { cout << -1 << endl; return 0; } cout << n + 1 << endl << low << endl; val = low; for (i = 0; i < n; i++) { if (i % 2 == 0) val = b[i] - val; else val = val - b[i]; cout << val << endl; } return 0; }