import std.algorithm;
import std.array;
import std.container;
import std.conv;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void scan(T...)(ref T a) {
    string[] ss = readln.split;
    foreach (i, t; T) a[i] = ss[i].to!t;
}
T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

void calc(int[] a) {
    auto mt = new long[a.length];

    long lo = 0;
    long hi = a[0];
    while (lo <= hi) {
        long m = (lo + hi) / 2; // 山 1 の雨の量

        mt[0] = m * 2;
        for (int i = 1; i < a.length; i++) {
            // 山 i の雨の量を求める
            long p = 2 * a[i-1] - mt[i-1];
            mt[i] = p;
        }

        long x = (mt[0] + mt[$-1]) / 2;
        if (x == a[$-1]) {
            writeln(mt.map!(text).join(" "));
            break;
        }
        else if (x > a[$-1]) {
            hi = m - 1;
        }
        else {
            lo = m + 1;
        }
    }
}

void main() {
    int n; scan(n);
    auto a = readints;
    calc(a);
}
