#include <iostream>
#include <string>
#include <map>
#include <math.h>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <set>
#include <queue>
#include <sstream>
#include <deque>
#include <memory.h>
#include <cassert>
#include <ctime>
#include <cstring>
 
 
using namespace std;
 
#define ll long long
 
const int maxn = 50000;
const int inf = 1e9;

int n;
int a[maxn], b[maxn];
 
int main() {
	freopen("sequence.in", "r", stdin);
	freopen("sequence.out", "w", stdout);

	cin >> n;
	for (int i = 1; i <= n; i++) cin >> a[i];

	b[0] = 0;
	b[1] = 0;
	b[2] = a[1];
	for (int it = 0; it < 2; it++) {
		for (int i = 3; i <= n + 1; i++) {
		 	// b[i - 2] + b[i - 1] + b[i] == a[i - 1]
			// b[i] = a[i - 1] - b[i - 2] - b[i - 1]
			b[i] = a[i - 1] - b[i - 2] - b[i - 1];
			// b[i - 1] + b[i - 2] = a[i - 2] - b[i - 3]
			// b[i] = a[i - 1] - a[i - 2] + b[i - 3]
			// consider b[0] = b[1] = 0, we achieve that b[n] will be not more than n * 2 / 3 * a_max
		}
		
		int mx[3] = {-inf};
		int mn[3] = {inf};
		
		for (int i = 0; i <= n + 1; i++) {
		 	mx[i % 3] = max(mx[i % 3], b[i]);
			mn[i % 3] = min(mn[i % 3], b[i]);
		}

		int k = 0;
		for (int i = 1; i <= 2; i++) if (max(abs(mn[i]), abs(mx[i])) > max(abs(mn[k]), abs(mx[k]))) k = i;
		
		if (mx[k] > inf) {
			for (int i = 0; i < 3; i++) {
			 	if (i == k) b[i] -= 3e8;
				else b[i] += 1.5e8;
			}
		} else if (mn[k] < -inf) {
			for (int i = 0; i < 3; i++) {
			 	if (i == k) b[i] += 3e8;
				else b[i] -= 1.5e8;
			}
		} else {
		 	break;
		}
	}
	// b[2] = a[1] - b[0] - b[1]           
	for (int i = 0; i <= n + 1; i++) {
		cout  << b[i] << " \n"[i == n + 1];
	}

    return 0;
}                                                                           