Language: C++

#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<unordered_set>
#include<cmath>
#include<numeric>
#include<iterator>
#include<set>
#include<unordered_map>
#include<map>
#include<queue>
#include<cstring>
#include<stdio.h>
#include<fstream>
#include<iomanip>
#include<functional>
#include<bitset>
#include<chrono>
#include<climits>
//#include<ext/pb_ds/assoc_container.hpp>
//#include<ext/pb_ds/tree_policy.hpp>

#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define foru(i , a , b) for(int i = (int)(a) ; i < (int)(b) ; i++)
#define ford(i , a , b) for(int i = (int)(a) ; i >= (int)(b) ; i--)
#define ain(a , n) for(int i = 0 ; i < (int)n ; i++) cin >> a[i]
#define aout(a , n) for(int i = 0 ; i < (int)n ; i++) cout << a[i] << " "; cend
#define M 1000000007
#define mp make_pair
#define mt make_tuple
#define cend cout << "\n"
#define all(x) x.begin() , x.end()
#define aout2(a , n , m) for(ll i = 0 ; i < n ; i++){for(ll j = 0 ; j < m ; j++){cout << a[i][j] << " ";} cout << endl;}
#define ain2(a , n , m) for(ll i = 0 ; i < n ; i++){for(ll j = 0 ; j < m ; j++){cin >> a[i][j];}}
#define ff first
#define ss second
#define sz(a) ((int)(a).size())
#define mset(a , b) memset(a , b , sizeof(a))
#ifndef ONLINE_JUDGE
#define dbg(a) cerr << #a << ": "; _print(a); cerr << endl;
#else
#define dbg(a) // No more TLEs

#endif

using namespace std;
using namespace std::chrono;
//using namespace __gnu_pbds;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ldb;
typedef vector <int> vi;
typedef vector <ll> vll;
typedef vector <char> vch;
typedef vector <string> vs;
typedef set <ll> sll;
typedef multiset <ll> msll;
typedef pair <ll , ll> pll;
typedef vector <pair <ll , ll>> vpll;
typedef vector <pair <int, int>> vpi;
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;


void _print(ll t){cerr<<t;}
void _print(int t){cerr<<t;}
void _print(string t){cerr<<t;}
void _print(char t){cerr<<t;}
void _print(ldb t){cerr<<t;}
void _print(double t){cerr<<t;}
void _print(ull t){cerr<<t;}

template <class T, class V> void _print(pair <T, V> p);
template <class T> void _print(vector <T> v);
template <class T> void _print(set <T> v);
template <class T, class V> void _print(map <T, V> v);
template <class T> void _print(multiset <T> v);
template <class T, class V> void _print(pair <T, V> p){cerr<< "{";_print(p.ff);cerr<<",";_print(p.ss);cerr<<"}";}
template <class T> void _print(vector <T> v){cerr<<"[ ";for(T i: v){_print(i);cerr<<" ";}cerr << "]";}
template <class T> void _print(set <T> v){cerr<<"[ ";for(T i: v){_print(i);cerr<<" ";}cerr << "]";}
template <class T> void _print(multiset <T> v){cerr<<"[ ";for(T i: v){_print(i);cerr<<" ";}cerr << "]";}
//void _print(ordered_set &v){cerr<<"[ ";for(int i: v){_print(i);cerr<<" ";}cerr << "]";}
template <class T, class V> void _print(map <T, V> v){cerr<<"[ ";for(auto i: v){_print(i);cerr<<" ";}cerr << "]";}

/*----------------------------- # --- MATH ALGORITHMS --- # -----------------------------*/

template <class T> T gcd(T a , T b){ while(a != 0){T temp = a; a = b % a; b = temp;}return b;}
template <class T> T egcd(T a , T b , T &x , T &y){T gcd , xt , yt;if(a == 0){gcd = b;x = 0 , y = 1;}else {gcd = egcd(b % a , a , xt , yt);x = yt - (b/a)*xt; y = xt;}return gcd;}
template <class T> T expo(T base , T exp , T mod){T res = 1;base = base % mod;while (exp > 0){if (exp & 1)res = (res*base) % mod;exp = exp>>1;base = (base*base) % mod;}return res;}
template <class T> T modinv(T a , T mod){T x , y; egcd<T>(a , mod , x , y);while(x < 0) x += mod; while(x >= mod) x -= mod; return x;}
template <class T> T modinvfermat(T a , T mod){return expo<T>(a , mod - 2 , mod);}
template <class T> bool rev(T a , T b){return a > b;}
template <class T> ll maxpower(T a , T b){ll ans = 0;while(a > 0 && a % b == 0){ans++;a /= b;}return ans;}
template <class T> T mceil(T a, T b){if(a % b == 0) return a/b; else return a/b + 1;}
template <class T> T lcm(T a, T b){return (a*b)/gcd<T>(a, b);}
const ll infl = 1e18 + 5; const int inf = 1e9 + 5;

/*----------------------------- # --- MAIN CODE --- # -----------------------------*/

void test_case(){
    int n; cin >> n; vll a(n); ain(a, n); vll b(n);
    vll lt, gt; vll pref(n);
    foru(i, 0, n) b[i] = 2*a[i];
    pref[0] = b[0];
    foru(i, 1, n){
        if(i % 2 == 0) pref[i] = pref[i - 1] + b[i];
        else pref[i] = pref[i - 1] - b[i];
    }
    foru(i, 0, n){
        if(i % 2 == 0) lt.push_back(pref[i]);
        else gt.push_back(pref[i]);
    }
    dbg(lt); dbg(gt);
    sort(all(lt)); sort(all(gt));
    ll r = lt[0];
    ll l = gt.back();
    ll aa = l + 2;
    cout << aa << " ";
    foru(i, 1, n){
        ll temp;
        if(i % 2 == 0) cout << pref[i] - aa << " ";
        else cout << aa - pref[i] << " ";
    }
}



int main() {
    fastio;
#ifndef ONLINE_JUDGE
    freopen("testcase.txt", "r", stdin);
    freopen("error.txt", "w", stderr);
    freopen("output.txt", "w", stdout);
#endif
    int _;
//    cin >> _;
    _ = 1;
    auto start = high_resolution_clock::now();
    cout << setprecision(20);
    while(_--){
        test_case();
    }
    auto stop = high_resolution_clock::now();
    auto duration = duration_cast<milliseconds>(stop - start);
#ifndef ONLINE_JUDGE
    cerr << "Time: " << duration.count() << endl;
#endif
    return 0;
}







#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<unordered_set>
#include<cmath>
#include<numeric>
#include<iterator>
#include<set>
#include<unordered_map>
#include<map>
#include<queue>
#include<cstring>
#include<stdio.h>
#include<fstream>
#include<iomanip>
#include<functional>
#include<bitset>
#include<chrono>
#include<climits>
//#include<ext/pb_ds/assoc_container.hpp>
//#include<ext/pb_ds/tree_policy.hpp>

#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define foru(i , a , b) for(int i = (int)(a) ; i < (int)(b) ; i++)
#define ford(i , a , b) for(int i = (int)(a) ; i >= (int)(b) ; i--)
#define ain(a , n) for(int i = 0 ; i < (int)n ; i++) cin >> a[i]
#define aout(a , n) for(int i = 0 ; i < (int)n ; i++) cout << a[i] << " "; cend
#define M 1000000007
#define mp make_pair
#define mt make_tuple
#define cend cout << "\n"
#define all(x) x.begin() , x.end()
#define aout2(a , n , m) for(ll i = 0 ; i < n ; i++){for(ll j = 0 ; j < m ; j++){cout << a[i][j] << " ";} cout << endl;}
#define ain2(a , n , m) for(ll i = 0 ; i < n ; i++){for(ll j = 0 ; j < m ; j++){cin >> a[i][j];}}
#define ff first
#define ss second
#define sz(a) ((int)(a).size())
#define mset(a , b) memset(a , b , sizeof(a))
#ifndef ONLINE_JUDGE
#define dbg(a) cerr << #a << ": "; _print(a); cerr << endl;
#else
#define dbg(a) // No more TLEs

#endif

using namespace std;
using namespace std::chrono;
//using namespace __gnu_pbds;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ldb;
typedef vector <int> vi;
typedef vector <ll> vll;
typedef vector <char> vch;
typedef vector <string> vs;
typedef set <ll> sll;
typedef multiset <ll> msll;
typedef pair <ll , ll> pll;
typedef vector <pair <ll , ll>> vpll;
typedef vector <pair <int, int>> vpi;
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;


void _print(ll t){cerr<<t;}
void _print(int t){cerr<<t;}
void _print(string t){cerr<<t;}
void _print(char t){cerr<<t;}
void _print(ldb t){cerr<<t;}
void _print(double t){cerr<<t;}
void _print(ull t){cerr<<t;}

template <class T, class V> void _print(pair <T, V> p);
template <class T> void _print(vector <T> v);
template <class T> void _print(set <T> v);
template <class T, class V> void _print(map <T, V> v);
template <class T> void _print(multiset <T> v);
template <class T, class V> void _print(pair <T, V> p){cerr<< "{";_print(p.ff);cerr<<",";_print(p.ss);cerr<<"}";}
template <class T> void _print(vector <T> v){cerr<<"[ ";for(T i: v){_print(i);cerr<<" ";}cerr << "]";}
template <class T> void _print(set <T> v){cerr<<"[ ";for(T i: v){_print(i);cerr<<" ";}cerr << "]";}
template <class T> void _print(multiset <T> v){cerr<<"[ ";for(T i: v){_print(i);cerr<<" ";}cerr << "]";}
//void _print(ordered_set &v){cerr<<"[ ";for(int i: v){_print(i);cerr<<" ";}cerr << "]";}
template <class T, class V> void _print(map <T, V> v){cerr<<"[ ";for(auto i: v){_print(i);cerr<<" ";}cerr << "]";}

/*----------------------------- # --- MATH ALGORITHMS --- # -----------------------------*/

template <class T> T gcd(T a , T b){ while(a != 0){T temp = a; a = b % a; b = temp;}return b;}
template <class T> T egcd(T a , T b , T &x , T &y){T gcd , xt , yt;if(a == 0){gcd = b;x = 0 , y = 1;}else {gcd = egcd(b % a , a , xt , yt);x = yt - (b/a)*xt; y = xt;}return gcd;}
template <class T> T expo(T base , T exp , T mod){T res = 1;base = base % mod;while (exp > 0){if (exp & 1)res = (res*base) % mod;exp = exp>>1;base = (base*base) % mod;}return res;}
template <class T> T modinv(T a , T mod){T x , y; egcd<T>(a , mod , x , y);while(x < 0) x += mod; while(x >= mod) x -= mod; return x;}
template <class T> T modinvfermat(T a , T mod){return expo<T>(a , mod - 2 , mod);}
template <class T> bool rev(T a , T b){return a > b;}
template <class T> ll maxpower(T a , T b){ll ans = 0;while(a > 0 && a % b == 0){ans++;a /= b;}return ans;}
template <class T> T mceil(T a, T b){if(a % b == 0) return a/b; else return a/b + 1;}
template <class T> T lcm(T a, T b){return (a*b)/gcd<T>(a, b);}
const ll infl = 1e18 + 5; const int inf = 1e9 + 5;

/*----------------------------- # --- MAIN CODE --- # -----------------------------*/

void test_case(){
    int n; cin >> n; vll a(n); ain(a, n); vll b(n);
    vll lt, gt; vll pref(n);
    foru(i, 0, n) b[i] = 2*a[i];
    pref[0] = b[0];
    foru(i, 1, n){
        if(i % 2 == 0) pref[i] = pref[i - 1] + b[i];
        else pref[i] = pref[i - 1] - b[i];
    }
    foru(i, 0, n){
        if(i % 2 == 0) lt.push_back(pref[i]);
        else gt.push_back(pref[i]);
    }
    dbg(lt); dbg(gt);
    sort(all(lt)); sort(all(gt));
    ll r = lt[0];
    ll l = gt.back();
    ll aa = l + 2;
    cout << aa << " ";
    foru(i, 1, n){
        ll temp;
        if(i % 2 == 0) cout << pref[i] - aa << " ";
        else cout << aa - pref[i] << " ";
    }
}



int main() {
    fastio;
#ifndef ONLINE_JUDGE
    freopen("testcase.txt", "r", stdin);
    freopen("error.txt", "w", stderr);
    freopen("output.txt", "w", stdout);
#endif
    int _;
//    cin >> _;
    _ = 1;
    auto start = high_resolution_clock::now();
    cout << setprecision(20);
    while(_--){
        test_case();
    }
    auto stop = high_resolution_clock::now();
    auto duration = duration_cast<milliseconds>(stop - start);
#ifndef ONLINE_JUDGE
    cerr << "Time: " << duration.count() << endl;
#endif
    return 0;
}









Compiler output:
a.cc:223:6: error: redefinition of 'void _print(ll)'
  223 | void _print(ll t){cerr<<t;}
      |      ^~~~~~
a.cc:66:6: note: 'void _print(ll)' previously defined here
   66 | void _print(ll t){cerr<<t;}
      |      ^~~~~~
a.cc:224:6: error: redefinition of 'void _print(int)'
  224 | void _print(int t){cerr<<t;}
      |      ^~~~~~
a.cc:67:6: note: 'void _print(int)' previously defined here
   67 | void _print(int t){cerr<<t;}
      |      ^~~~~~
a.cc:225:6: error: redefinition of 'void _print(std::string)'
  225 | void _print(string t){cerr<<t;}
      |      ^~~~~~
a.cc:68:6: note: 'void _print(std::string)' previously defined here
   68 | void _print(string t){cerr<<t;}
      |      ^~~~~~
a.cc:226:6: error: redefinition of 'void _print(char)'
  226 | void _print(char t){cerr<<t;}
      |      ^~~~~~
a.cc:69:6: note: 'void _print(char)' previously defined here
   69 | void _print(char t){cerr<<t;}
      |      ^~~~~~
a.cc:227:6: error: redefinition of 'void _print(ldb)'
  227 | void _print(ldb t){cerr<<t;}
      |      ^~~~~~
a.cc:70:6: note: 'void _print(ldb)' previously defined here
   70 | void _print(ldb t){cerr<<t;}
      |      ^~~~~~
a.cc:228:6: error: redefinition of 'void _print(double)'
  228 | void _print(double t){cerr<<t;}
      |      ^~~~~~
a.cc:71:6: note: 'void _print(double)' previously defined here
   71 | void _print(double t){cerr<<t;}
      |      ^~~~~~
a.cc:229:6: error: redefinition of 'void _print(ull)'
  229 | void _print(ull t){cerr<<t;}
      |      ^~~~~~
a.cc:72:6: note: 'void _print(ull)' previously defined here
   72 | void _print(ull t){cerr<<t;}
      |      ^~~~~~
a.cc:236:34: error: redefinition of 'template<class T, class V> void _print(std::pair<_T1, _T2>)'
  236 | template <class T, class V> void _print(pair <T, V> p){cerr<< "{";_print(p.ff);cerr<<",";_print(p.ss);cerr<<"}";}
      |                                  ^~~~~~
a.cc:79:34: note: 'template<class T, class V> void _print(std::pair<_T1, _T2>)' previously declared here
   79 | template <class T, class V> void _print(pair <T, V> p){cerr<< "{";_print(p.ff);cerr<<",";_print(p.ss);cerr<<"}";}
      |                                  ^~~~~~
a.cc:237:25: error: redefinition of 'template<class T> void _print(std::vector<_Tp>)'
  237 | template <class T> void _print(vector <T> v){cerr<<"[ ";for(T i: v){_print(i);cerr<<" ";}cerr << "]";}
      |                         ^~~~~~
a.cc:80:25: note: 'template<class T> void _print(std::vector<_Tp>)' previously declared here
   80 | template <class T> void _print(vector <T> v){cerr<<"[ ";for(T i: v){_print(i);cerr<<" ";}cerr << "]";}
      |                         ^~~~~~
a.cc:238:25: error: redefinition of 'template<class T> void _print(std::set<T>)'
  238 | template <class T> void _print(set <T> v){cerr<<"[ ";for(T i: v){_print(i);cerr<<" ";}cerr << "]";}
      |                         ^~~~~~
a.cc:81:25: note: 'template<class T> void _print(std::set<T>)' previously declared here
   81 | template <class T> void _print(set <T> v){cerr<<"[ ";for(T i: v){_print(i);cerr<<" ";}cerr << "]";}
      |                         ^~~~~~
a.cc:239:25: error: redefinition of 'template<class T> void _print(std::multiset<T>)'
  239 | template <class T> void _print(multiset <T> v){cerr<<"[ ";for(T i: v){_print(i);cerr<<" ";}cerr << "]";}
      |                         ^~~~~~
a.cc:82:25: note: 'template<class T> void _print(std::multiset<T>)' previously declared here
   82 | template <class T> void _print(multiset <T> v){cerr<<"[ ";for(T i: v){_print(i);cerr<<" ";}cerr << "]";}
      |                         ^~~~~~
a.cc:241:34: error: redefinition of 'template<class T, class V> void _print(std::map<T, V>)'
  241 | template <class T, class V> void _print(map <T, V> v){cerr<<"[ ";for(auto i: v){_print(i);cerr<<" ";}cerr << "]";}
      |                                  ^~~~~~
a.cc:84:34: note: 'template<class T, class V> void _print(std::map<T, V>)' previously declared here
   84 | template <class T, class V> void _print(map <T, V> v){cerr<<"[ ";for(auto i: v){_print(i);cerr<<" ";}cerr << "]";}
      |                                  ^~~~~~
a.cc:245:22: error: redefinition of 'template<class T> T gcd(T, T)'
  245 | template <class T> T gcd(T a , T b){ while(a != 0){T temp = a; a = b % a; b = temp;}return b;}
      |                      ^~~
a.cc:88:22: note: 'template<class T> T gcd(T, T)' previously declared here
   88 | template <class T> T gcd(T a , T b){ while(a != 0){T temp = a; a = b % a; b = temp;}return b;}
      |                      ^~~
a.cc:246:22: error: redefinition of 'template<class T> T egcd(T, T, T&, T&)'
  246 | template <class T> T egcd(T a , T b , T &x , T &y){T gcd , xt , yt;if(a == 0){gcd = b;x = 0 , y = 1;}else {gcd = egcd(b % a , a , xt , yt);x = yt - (b/a)*xt; y = xt;}return gcd;}
      |                      ^~~~
a.cc:89:22: note: 'template<class T> T egcd(T, T, T&, T&)' previously declared here
   89 | template <class T> T egcd(T a , T b , T &x , T &y){T gcd , xt , yt;if(a == 0){gcd = b;x = 0 , y = 1;}else {gcd = egcd(b % a , a , xt , yt);x = yt - (b/a)*xt; y = xt;}return gcd;}
      |                      ^~~~
a.cc:247:22: error: redefinition of 'template<class T> T expo(T, T, T)'
  247 | template <class T> T expo(T base , T exp , T mod){T res = 1;base = base % mod;while (exp > 0){if (exp & 1)res = (res*base) % mod;exp = exp>>1;base = (base*base) % mod;}return res;}
      |                      ^~~~
a.cc:90:22: note: 'template<class T> T expo(T, T, T)' previously declared here
   90 | template <class T> T expo(T base , T exp , T mod){T res = 1;base = base % mod;while (exp > 0){if (exp & 1)res = (res*base) % mod;exp = exp>>1;base = (base*base) % mod;}return res;}
      |                      ^~~~
a.cc:248:22: error: redefinition of 'template<class T> T modinv(T, T)'
  248 | template <class T> T modinv(T a , T mod){T x , y; egcd<T>(a , mod , x , y);while(x < 0) x += mod; while(x >= mod) x -= mod; return x;}
      |                      ^~~~~~
a.cc:91:22: note: 'template<class T> T modinv(T, T)' previously declared here
   91 | template <class T> T modinv(T a , T mod){T x , y; egcd<T>(a , mod , x , y);while(x < 0) x += mod; while(x >= mod) x -= mod; return x;}
      |                      ^~~~~~
a.cc:249:22: error: redefinition of 'template<class T> T modinvfermat(T, T)'
  249 | template <class T> T modinvfermat(T a , T mod){return expo<T>(a , mod - 2 , mod);}
      |                      ^~~~~~~~~~~~
a.cc:92:22: note: 'template<class T> T modinvfermat(T, T)' previously declared here
   92 | template <class T> T modinvfermat(T a , T mod){return expo<T>(a , mod - 2 , mod);}
      |                      ^~~~~~~~~~~~
a.cc:250:25: error: redefinition of 'template<class T> bool rev(T, T)'
  250 | template <class T> bool rev(T a , T b){return a > b;}
      |                         ^~~
a.cc:93:25: note: 'template<class T> bool rev(T, T)' previously declared here
   93 | template <class T> bool rev(T a , T b){return a > b;}
      |                         ^~~
a.cc:251:23: error: redefinition of 'template<class T> ll maxpower(T, T)'
  251 | template <class T> ll maxpower(T a , T b){ll ans = 0;while(a > 0 && a % b == 0){ans++;a /= b;}return ans;}
      |                       ^~~~~~~~
a.cc:94:23: note: 'template<class T> ll maxpower(T, T)' previously declared here
   94 | template <class T> ll maxpower(T a , T b){ll ans = 0;while(a > 0 && a % b == 0){ans++;a /= b;}return ans;}
      |                       ^~~~~~~~
a.cc:252:22: error: redefinition of 'template<class T> T mceil(T, T)'
  252 | template <class T> T mceil(T a, T b){if(a % b == 0) return a/b; else return a/b + 1;}
      |                      ^~~~~
a.cc:95:22: note: 'template<class T> T mceil(T, T)' previously declared here
   95 | template <class T> T mceil(T a, T b){if(a % b == 0) return a/b; else return a/b + 1;}
      |                      ^~~~~
a.cc:253:22: error: redefinition of 'template<class T> T lcm(T, T)'
  253 | template <class T> T lcm(T a, T b){return (a*b)/gcd<T>(a, b);}
      |                      ^~~
a.cc:96:22: note: 'template<class T> T lcm(T, T)' previously declared here
   96 | template <class T> T lcm(T a, T b){return (a*b)/gcd<T>(a, b);}
      |                      ^~~
a.cc:254:10: error: redefinition of 'const ll infl'
  254 | const ll infl = 1e18 + 5; const int inf = 1e9 + 5;
      |          ^~~~
a.cc:97:10: note: 'const ll infl' previously defined here
   97 | const ll infl = 1e18 + 5; const int inf = 1e9 + 5;
      |          ^~~~
a.cc:254:37: error: redefinition of 'const int inf'
  254 | const ll infl = 1e18 + 5; const int inf = 1e9 + 5;
      |                                     ^~~
a.cc:97:37: note: 'const int inf' previously defined here
   97 | const ll infl = 1e18 + 5; const int inf = 1e9 + 5;
      |                                     ^~~
a.cc:258:6: error: redefinition of 'void test_case()'
  258 | void test_case(){
      |      ^~~~~~~~~
a.cc:101:6: note: 'void test_case()' previously defined here
  101 | void test_case(){
      |      ^~~~~~~~~
a.cc:286:5: error: redefinition of 'int main()'
  286 | int main() {
      |     ^~~~
a.cc:129:5: note: 'int main()' previously defined here
  129 | int main() {
      |     ^~~~