#include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long ll; typedef unsigned long long ull; typedef pair pii; typedef vector vi; const ll INF = 1000000000ll * 1000000000ll; ll B[100010]; int N; int main() { cin >> N; for (int i = 0; i < N; i++) cin >> B[i]; ll low = 1, high = INF; ll now = 0; for (int i = 0; i < N; i++) { if (i%2 == 0) now = B[i]-now; else now = now-B[i]; if ((i/2)%2 == 0) high = min(high, now-1); else low = max(low, -now+1); } if (low > high) cout << -1 << endl; else { cout << low << endl; ll now = low; for (int i = 0; i < N; i++) { if (i%2 == 0) now = B[i]-now; else now = now-B[i]; cout << now << endl; } } return 0; }