#include #include using namespace std; typedef unsigned long long ll; const ll x = 1e18; int main(){ int n; cin >> n; ll b[n]; for(int i = 0; i < n; i++) cin >> b[i]; for(int i = 0; i < n; i++){ if(i%2){ if(b[i] >= b[i-1]){ cout << "-1" << endl; return 0; } }else{ if(b[i] == 1){ cout << "-1" << endl; return 0; } } } vector ans(n+1); ll first = 1; while(1){ if(first <= 0 || first >= b[0]){ cout << "-1" << endl; return 0; } ans[0] = first; int i; for(i = 0; i < n; i++){ if(i%2){ ll tmp = ans[i]-b[i]; if(tmp <= 0){ first += -tmp+1; break; } ans[i+1] = tmp; }else{ ll tmp = b[i]-ans[i]; if(tmp <= 0){ first += -tmp+1; break; } ans[i+1] = tmp; } } if(i == n) break; } cout << n+1 << endl; for(ll i : ans) cout << i << endl; return 0; }