#include <bits/stdc++.h>
#define endl '\n'
#define ll long long
#define ull unsigned long long
#define fi first
#define se second
#define mp make_pair
#define pii pair<int,int>
#define all(x) x.begin(),x.end()
#define IO ios::sync_with_stdio(false)
#define rep(ii,a,b) for(int ii=a;ii<=b;++ii)
#define per(ii,a,b) for(int ii=b;ii>=a;--ii)
#define forn(ii,x) for(int ii=head[x];ii;ii=e[ii].next)
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#define inline inline __attribute__(                               \
(always_inline, __gnu_inline__, __artificial__))                   \
__attribute__((optimize("Ofast"))) __attribute__((target("sse"))) \
__attribute__((target("sse2"))) __attribute__((target("mmx")))
#define show(x) cout<<#x<<"="<<x<<endl
#define show2(x,y) cout<<#x<<"="<<x<<" "<<#y<<"="<<y<<endl
#define show3(x,y,z) cout<<#x<<"="<<x<<" "<<#y<<"="<<y<<" "<<#z<<"="<<z<<endl
#define show4(w,x,y,z) cout<<#w<<"="<<w<<" "<<#x<<"="<<x<<" "<<#y<<"="<<y<<" "<<#z<<"="<<z<<endl
#define show5(v,w,x,y,z) cout<<#v<<" "<<v<<" "<<#w<<"="<<w<<" "<<#x<<"="<<x<<" "<<#y<<"="<<y<<" "<<#z<<"="<<z<<endl
#define showa(a,b) cout<<#a<<'['<<b<<"]="<<a[b]<<endl
using namespace std;
const int maxn=1e6+10,maxm=2e6+10;
const int INF=0x3f3f3f3f;
const int mod=1e9+7;
const double PI=acos(-1.0);
//head
int casn,n,m,k;
ll num[maxn];
ll ans[maxn];
int main() {
//#define test
#ifdef test
	auto _start = chrono::high_resolution_clock::now();
	freopen("in.txt","r",stdin);freopen("out.txt","w",stdout);
#endif
	cin>>n;
	memset(ans,0,sizeof ans);
	rep(i,1,n/2){
		cin>>num[i];
	}
	ans[n+1]=INF;
	rep(i,1,n/2){
		ans[n-i+1]=min(num[i],ans[n-i+2]);
		ans[i]=max(num[i]-ans[n-i+1],ans[i-1]);
	}
	rep(i,1,n/2){
		if(ans[n-i+1]<ans[i]) swap(ans[i],ans[n-i+1]);
	}
	rep(i,1,n)cout<<ans[i]<<' ';
	cout<<endl;

#ifdef test
	auto _end = chrono::high_resolution_clock::now();
  cerr << "elapsed time: " << chrono::duration<double, milli>(_end - _start).count() << " ms\n";
	fclose(stdin);fclose(stdout);system("out.txt");
#endif
	return 0;
}


#include <bits/stdc++.h>
#define endl '\n'
#define ll long long
#define ull unsigned long long
#define fi first
#define se second
#define mp make_pair
#define pii pair<int,int>
#define all(x) x.begin(),x.end()
#define IO ios::sync_with_stdio(false)
#define rep(ii,a,b) for(int ii=a;ii<=b;++ii)
#define per(ii,a,b) for(int ii=b;ii>=a;--ii)
#define forn(ii,x) for(int ii=head[x];ii;ii=e[ii].next)
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#define inline inline __attribute__(                               \
(always_inline, __gnu_inline__, __artificial__))                   \
__attribute__((optimize("Ofast"))) __attribute__((target("sse"))) \
__attribute__((target("sse2"))) __attribute__((target("mmx")))
#define show(x) cout<<#x<<"="<<x<<endl
#define show2(x,y) cout<<#x<<"="<<x<<" "<<#y<<"="<<y<<endl
#define show3(x,y,z) cout<<#x<<"="<<x<<" "<<#y<<"="<<y<<" "<<#z<<"="<<z<<endl
#define show4(w,x,y,z) cout<<#w<<"="<<w<<" "<<#x<<"="<<x<<" "<<#y<<"="<<y<<" "<<#z<<"="<<z<<endl
#define show5(v,w,x,y,z) cout<<#v<<" "<<v<<" "<<#w<<"="<<w<<" "<<#x<<"="<<x<<" "<<#y<<"="<<y<<" "<<#z<<"="<<z<<endl
#define showa(a,b) cout<<#a<<'['<<b<<"]="<<a[b]<<endl
using namespace std;
const int maxn=1e6+10,maxm=2e6+10;
const int INF=0x3f3f3f3f;
const int mod=1e9+7;
const double PI=acos(-1.0);
//head
int casn,n,m,k;
int num[maxn];
int ans[maxn];
int main() {
//#define test
#ifdef test
	auto _start = chrono::high_resolution_clock::now();
	freopen("in.txt","r",stdin);freopen("out.txt","w",stdout);
#endif
	cin>>n;
	memset(ans,0,sizeof ans);
	rep(i,1,n/2){
		cin>>num[i];
	}
	ans[n+1]=INF;
	rep(i,1,n/2){
		ans[n-i+1]=num[i];
		if(ans[n-i+1]>ans[n-i+2]){
			ans[n-i+1]=ans[n-i+2];
			ans[i]=num[i]-ans[n-i+2];
		}
	}
	rep(i,1,n)cout<<ans[i]<<' ';
	cout<<endl;

#ifdef test
	auto _end = chrono::high_resolution_clock::now();
  cerr << "elapsed time: " << chrono::duration<double, milli>(_end - _start).count() << " ms\n";
	fclose(stdin);fclose(stdout);system("out.txt");
#endif
	return 0;
}


#include <bits/stdc++.h>
#define endl '\n'
#define ll long long
#define ull unsigned long long
#define fi first
#define se second
#define mp make_pair
#define pii pair<int,int>
#define all(x) x.begin(),x.end()
#define IO ios::sync_with_stdio(false)
#define rep(ii,a,b) for(int ii=a;ii<=b;++ii)
#define per(ii,a,b) for(int ii=b;ii>=a;--ii)
#define forn(ii,x) for(int ii=head[x];ii;ii=e[ii].next)
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#define inline inline __attribute__(                               \
(always_inline, __gnu_inline__, __artificial__))                   \
__attribute__((optimize("Ofast"))) __attribute__((target("sse"))) \
__attribute__((target("sse2"))) __attribute__((target("mmx")))
#define show(x) cout<<#x<<"="<<x<<endl
#define show2(x,y) cout<<#x<<"="<<x<<" "<<#y<<"="<<y<<endl
#define show3(x,y,z) cout<<#x<<"="<<x<<" "<<#y<<"="<<y<<" "<<#z<<"="<<z<<endl
#define show4(w,x,y,z) cout<<#w<<"="<<w<<" "<<#x<<"="<<x<<" "<<#y<<"="<<y<<" "<<#z<<"="<<z<<endl
#define show5(v,w,x,y,z) cout<<#v<<" "<<v<<" "<<#w<<"="<<w<<" "<<#x<<"="<<x<<" "<<#y<<"="<<y<<" "<<#z<<"="<<z<<endl
#define showa(a,b) cout<<#a<<'['<<b<<"]="<<a[b]<<endl
using namespace std;
const int maxn=1e6+10,maxm=2e6+10;
const int INF=0x3f3f3f3f;
const int mod=1e9+7;
const double PI=acos(-1.0);
//head
int casn,n,m,k;
ll num[maxn];
ll ans[maxn];
int main() {
//#define test
#ifdef test
	auto _start = chrono::high_resolution_clock::now();
	freopen("in.txt","r",stdin);freopen("out.txt","w",stdout);
#endif
	cin>>n;
	memset(ans,0,sizeof ans);
	rep(i,1,n/2){
		cin>>num[i];
	}
	ans[n+1]=1e18;
	rep(i,1,n/2){
		ans[n-i+1]=min(num[i],ans[n-i+2]);
		ans[i]=num[i]-ans[n-i+1];
		if(ans[i]<ans[i-1]){
			ans[i]=ans[i-1];
			ans[n-i+1]=num[i]-ans[i];
		}
	}
	rep(i,1,n/2){
		if(ans[n-i+1]<ans[i]) swap(ans[i],ans[n-i+1]);
	}
	rep(i,1,n)cout<<ans[i]<<' ';
	cout<<endl;

#ifdef test
	auto _end = chrono::high_resolution_clock::now();
  cerr << "elapsed time: " << chrono::duration<double, milli>(_end - _start).count() << " ms\n";
	fclose(stdin);fclose(stdout);system("out.txt");
#endif
	return 0;
}


#include <bits/stdc++.h>
#define endl '\n'
#define ll long long
#define ull unsigned long long
#define fi first
#define se second
#define mp make_pair
#define pii pair<int,int>
#define all(x) x.begin(),x.end()
#define IO ios::sync_with_stdio(false)
#define rep(ii,a,b) for(int ii=a;ii<=b;++ii)
#define per(ii,a,b) for(int ii=b;ii>=a;--ii)
#define forn(ii,x) for(int ii=head[x];ii;ii=e[ii].next)
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#define inline inline __attribute__(                               \
(always_inline, __gnu_inline__, __artificial__))                   \
__attribute__((optimize("Ofast"))) __attribute__((target("sse"))) \
__attribute__((target("sse2"))) __attribute__((target("mmx")))
#define show(x) cout<<#x<<"="<<x<<endl
#define show2(x,y) cout<<#x<<"="<<x<<" "<<#y<<"="<<y<<endl
#define show3(x,y,z) cout<<#x<<"="<<x<<" "<<#y<<"="<<y<<" "<<#z<<"="<<z<<endl
#define show4(w,x,y,z) cout<<#w<<"="<<w<<" "<<#x<<"="<<x<<" "<<#y<<"="<<y<<" "<<#z<<"="<<z<<endl
#define show5(v,w,x,y,z) cout<<#v<<" "<<v<<" "<<#w<<"="<<w<<" "<<#x<<"="<<x<<" "<<#y<<"="<<y<<" "<<#z<<"="<<z<<endl
#define showa(a,b) cout<<#a<<'['<<b<<"]="<<a[b]<<endl
using namespace std;
const int maxn=1e6+10,maxm=2e6+10;
const int INF=0x3f3f3f3f;
const int mod=1e9+7;
const double PI=acos(-1.0);
//head
int casn,n,m,k;
ll num[maxn];
ll ans[maxn];
int main() {
//#define test
#ifdef test
	auto _start = chrono::high_resolution_clock::now();
	freopen("in.txt","r",stdin);freopen("out.txt","w",stdout);
#endif
	cin>>n;
	memset(ans,0,sizeof ans);
	rep(i,1,n/2){
		cin>>num[i];
	}
	ans[n+1]=INF;
	rep(i,1,n/2){
		ans[n-i+1]=num[i];
		if(ans[n-i+1]>ans[n-i+2]){
			ans[n-i+1]=ans[n-i+2];
			ans[i]=num[i]-ans[n-i+2];
		}
	}
	rep(i,1,n/2){
		if(ans[n-i+1]<ans[i]) swap(ans[i],ans[n-i+1]);
	}
	rep(i,1,n)cout<<ans[i]<<' ';
	cout<<endl;

#ifdef test
	auto _end = chrono::high_resolution_clock::now();
  cerr << "elapsed time: " << chrono::duration<double, milli>(_end - _start).count() << " ms\n";
	fclose(stdin);fclose(stdout);system("out.txt");
#endif
	return 0;
}


#include <bits/stdc++.h>
#define endl '\n'
#define ll long long
#define ull unsigned long long
#define fi first
#define se second
#define mp make_pair
#define pii pair<int,int>
#define all(x) x.begin(),x.end()
#define IO ios::sync_with_stdio(false)
#define rep(ii,a,b) for(int ii=a;ii<=b;++ii)
#define per(ii,a,b) for(int ii=b;ii>=a;--ii)
#define forn(ii,x) for(int ii=head[x];ii;ii=e[ii].next)
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#define inline inline __attribute__(                               \
(always_inline, __gnu_inline__, __artificial__))                   \
__attribute__((optimize("Ofast"))) __attribute__((target("sse"))) \
__attribute__((target("sse2"))) __attribute__((target("mmx")))
#define show(x) cout<<#x<<"="<<x<<endl
#define show2(x,y) cout<<#x<<"="<<x<<" "<<#y<<"="<<y<<endl
#define show3(x,y,z) cout<<#x<<"="<<x<<" "<<#y<<"="<<y<<" "<<#z<<"="<<z<<endl
#define show4(w,x,y,z) cout<<#w<<"="<<w<<" "<<#x<<"="<<x<<" "<<#y<<"="<<y<<" "<<#z<<"="<<z<<endl
#define show5(v,w,x,y,z) cout<<#v<<" "<<v<<" "<<#w<<"="<<w<<" "<<#x<<"="<<x<<" "<<#y<<"="<<y<<" "<<#z<<"="<<z<<endl
#define showa(a,b) cout<<#a<<'['<<b<<"]="<<a[b]<<endl
using namespace std;
const int maxn=1e6+10,maxm=2e6+10;
const int INF=0x3f3f3f3f;
const int mod=1e9+7;
const double PI=acos(-1.0);
//head
int casn,n,m,k;
ll num[maxn];
ll ans[maxn];
int main() {
//#define test
#ifdef test
	auto _start = chrono::high_resolution_clock::now();
	freopen("in.txt","r",stdin);freopen("out.txt","w",stdout);
#endif
	cin>>n;
	memset(ans,0,sizeof ans);
	rep(i,1,n/2){
		cin>>num[i];
	}
	ans[n+1]=INF;
	rep(i,1,n/2){
		ans[n-i+1]=num[i];
		if(ans[n-i+1]>ans[n-i+2]){
			ans[n-i+1]=ans[n-i+2];
			ans[i]=num[i]-ans[n-i+2];
		}
	}
	rep(i,1,n)cout<<ans[i]<<' ';
	cout<<endl;

#ifdef test
	auto _end = chrono::high_resolution_clock::now();
  cerr << "elapsed time: " << chrono::duration<double, milli>(_end - _start).count() << " ms\n";
	fclose(stdin);fclose(stdout);system("out.txt");
#endif
	return 0;
}


#include <bits/stdc++.h>
#define endl '\n'
#define ll long long
#define ull unsigned long long
#define fi first
#define se second
#define mp make_pair
#define pii pair<int,int>
#define all(x) x.begin(),x.end()
#define IO ios::sync_with_stdio(false)
#define rep(ii,a,b) for(int ii=a;ii<=b;++ii)
#define per(ii,a,b) for(int ii=b;ii>=a;--ii)
#define forn(ii,x) for(int ii=head[x];ii;ii=e[ii].next)
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#define inline inline __attribute__(                               \
(always_inline, __gnu_inline__, __artificial__))                   \
__attribute__((optimize("Ofast"))) __attribute__((target("sse"))) \
__attribute__((target("sse2"))) __attribute__((target("mmx")))
#define show(x) cout<<#x<<"="<<x<<endl
#define show2(x,y) cout<<#x<<"="<<x<<" "<<#y<<"="<<y<<endl
#define show3(x,y,z) cout<<#x<<"="<<x<<" "<<#y<<"="<<y<<" "<<#z<<"="<<z<<endl
#define show4(w,x,y,z) cout<<#w<<"="<<w<<" "<<#x<<"="<<x<<" "<<#y<<"="<<y<<" "<<#z<<"="<<z<<endl
#define show5(v,w,x,y,z) cout<<#v<<" "<<v<<" "<<#w<<"="<<w<<" "<<#x<<"="<<x<<" "<<#y<<"="<<y<<" "<<#z<<"="<<z<<endl
#define showa(a,b) cout<<#a<<'['<<b<<"]="<<a[b]<<endl
using namespace std;
const int maxn=1e6+10,maxm=2e6+10;
const int INF=0x3f3f3f3f;
const int mod=1e9+7;
const double PI=acos(-1.0);
//head
int casn,n,m,k;
ll num[maxn];
ll ans[maxn];
int main() {
//#define test
#ifdef test
	auto _start = chrono::high_resolution_clock::now();
	freopen("in.txt","r",stdin);freopen("out.txt","w",stdout);
#endif
	cin>>n;
	memset(ans,0,sizeof ans);
	rep(i,1,n/2){
		cin>>num[i];
	}
	ans[n+1]=INF;
	rep(i,1,n/2){
		ans[n-i+1]=min(num[i],ans[n-i+2]);
		ans[i]=num[i]-ans[n-i+1];
		if(ans[i]<ans[i-1]){
			ans[i]=ans[i-1];
			ans[n-i+1]=num[i]-ans[i];
		}
	}
	rep(i,1,n/2){
		if(ans[n-i+1]<ans[i]) swap(ans[i],ans[n-i+1]);
	}
	rep(i,1,n)cout<<ans[i]<<' ';
	cout<<endl;

#ifdef test
	auto _end = chrono::high_resolution_clock::now();
  cerr << "elapsed time: " << chrono::duration<double, milli>(_end - _start).count() << " ms\n";
	fclose(stdin);fclose(stdout);system("out.txt");
#endif
	return 0;
}


#include <bits/stdc++.h>
#define endl '\n'
#define ll long long
#define ull unsigned long long
#define fi first
#define se second
#define mp make_pair
#define pii pair<int,int>
#define all(x) x.begin(),x.end()
#define IO ios::sync_with_stdio(false)
#define rep(ii,a,b) for(int ii=a;ii<=b;++ii)
#define per(ii,a,b) for(int ii=b;ii>=a;--ii)
#define forn(ii,x) for(int ii=head[x];ii;ii=e[ii].next)
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#define inline inline __attribute__(                               \
(always_inline, __gnu_inline__, __artificial__))                   \
__attribute__((optimize("Ofast"))) __attribute__((target("sse"))) \
__attribute__((target("sse2"))) __attribute__((target("mmx")))
#define show(x) cout<<#x<<"="<<x<<endl
#define show2(x,y) cout<<#x<<"="<<x<<" "<<#y<<"="<<y<<endl
#define show3(x,y,z) cout<<#x<<"="<<x<<" "<<#y<<"="<<y<<" "<<#z<<"="<<z<<endl
#define show4(w,x,y,z) cout<<#w<<"="<<w<<" "<<#x<<"="<<x<<" "<<#y<<"="<<y<<" "<<#z<<"="<<z<<endl
#define show5(v,w,x,y,z) cout<<#v<<" "<<v<<" "<<#w<<"="<<w<<" "<<#x<<"="<<x<<" "<<#y<<"="<<y<<" "<<#z<<"="<<z<<endl
#define showa(a,b) cout<<#a<<'['<<b<<"]="<<a[b]<<endl
using namespace std;
const int maxn=1e6+10,maxm=2e6+10;
const int INF=0x3f3f3f3f;
const int mod=1e9+7;
const double PI=acos(-1.0);
//head
int casn,n,m,k;
ll num[maxn];
ll ans[maxn];
int main() {
//#define test
#ifdef test
	auto _start = chrono::high_resolution_clock::now();
	freopen("in.txt","r",stdin);freopen("out.txt","w",stdout);
#endif
	cin>>n;
	memset(ans,0,sizeof ans);
	rep(i,1,n/2){
		cin>>num[i];
	}
	ans[n+1]=INF;
	rep(i,1,n/2){
		ans[n-i+1]=min(num[i],ans[n-i+2]);
		ans[i]=num[i]-ans[n-i+1];
		if(ans[i]<ans[i-1]){
			ans[i]=ans[i-1];
			ans[n-i+1]-=ans[i];
		}
	}
	rep(i,1,n/2){
		if(ans[n-i+1]<ans[i]) swap(ans[i],ans[n-i+1]);
	}
	rep(i,1,n)cout<<ans[i]<<' ';
	cout<<endl;

#ifdef test
	auto _end = chrono::high_resolution_clock::now();
  cerr << "elapsed time: " << chrono::duration<double, milli>(_end - _start).count() << " ms\n";
	fclose(stdin);fclose(stdout);system("out.txt");
#endif
	return 0;
}


#include<bits/stdc++.h>
#define ll unsigned long long
#define hell 998244353
using namespace std;
int main()
{
	ll  n,i,k,j;cin>>n;
	vector<ll>b;
	vector<ll>a;
	for(i=0;i<n/2;i++)
	{
		cin>>k;
		b.push_back(k);
	}
	a.push_back(0);
	a.push_back(b[0]);
	k=a.size()-1;
	for(i=1;i<n/2;i++)
	{
		for(j=a[i-1];1;j++)
		{
			if(b[i]-j<=a[k])
			{
				a.insert(a.begin()+i,j);
				a.insert(a.begin()+i+1,b[i]-j);
				break;
			}
		}
		k++;
	}
	for(i=0;i<a.size();i++)
	cout<<a[i]<<" ";
}


#include<bits/stdc++.h>
#define ll unsigned long long
#define hell 998244353
using namespace std;
int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	ll  n,i,k,j;cin>>n;
	vector<ll>b;
	vector<ll>a;
	for(i=0;i<n/2;i++)
	{
		cin>>k;
		b.push_back(k);
	}
	a.push_back(0);
	a.push_back(b[0]);
	k=a.size()-1;
	for(i=1;i<n/2;i++)
	{
		for(j=a[i-1];1;j++)
		{
			if(b[i]-j<=a[k])
			{
				a.insert(a.begin()+i,j);
				a.insert(a.begin()+i+1,b[i]-j);
				break;
			}
		}
		k++;
	}
	for(i=0;i<a.size();i++)
	cout<<a[i]<<" ";
}


#include<bits/stdc++.h>
#define ll unsigned long long
#define hell 998244353
using namespace std;
int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	ll  n,i,k,j;cin>>n;
	vector<ll>b;
	vector<ll>a;
	for(i=0;i<n/2;i++)
	{
		cin>>k;
		b.push_back(k);
	}
	a.push_back(0);
	a.push_back(b[0]);
	k=a.size()-1;
	for(i=1;i<n/2;i++)
	{
		if((b[i]-a[i-1])<=a[k])
		{
			a.insert(a.begin()+i,b[i]-a[i-1]);
			a.insert(a.begin()+i,a[i-1]);

		}
		else
		{
			ll r=b[i]-a[k];
			a.insert(a.begin()+i,a[k]);
			a.insert(a.begin()+i,b[i]-a[k]);

		}
	  k++;
	}
	for(i=0;i<a.size();i++)
	cout<<a[i]<<" ";
}


#include<bits/stdc++.h>
#define ll unsigned long long
using namespace std;
int main()
{
	ll n;cin>>n;
	ll b[n],a[n/2],i;
	for(i=0;i<n/2;i++)
	cin>>a[i];
	b[0]=0;
	b[n-1]=a[0];
	for(i=1;i<n/2;i++)
	{
		if(a[i]-a[i-1]>=0)
		{
			b[i]=a[i]-b[n-i];
			b[n-1-i]=b[n-i];
		}
		else
		{
			b[i]=b[i-1];
			b[n-1-i]=a[i]-b[i];
		}
	}
	for(i=0;i<n;i++)
	cout<<b[i]<<" ";
}


#include<bits/stdc++.h>
#define ll unsigned long long
#define hell 998244353
using namespace std;
int main()
{
	ll  n,i,k,j;cin>>n;
	vector<ll>b;
	vector<ll>a;
	for(i=0;i<n/2;i++)
	{
		cin>>k;
		b.push_back(k);
	}
	a.push_back(0);
	a.push_back(b[0]);
	k=a.size()-1;
	for(i=1;i<n/2;i++)
	{
		for(j=a[i-1];1;j++)
		{
			if(b[i]-j<=a[k])
			{
				a.insert(a.begin()+i,j);
				a.insert(a.begin()+i+1,b[i]-j);
				break;
			}
		}
		k+=i;
	}
	for(i=0;i<a.size();i++)
	cout<<a[i]<<" ";
}


#include <bits/stdc++.h>
#define ll long long
#define mod 1000000007
using namespace std;
int main() {
   ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin>>n;
    ll a[n+2];
    memset(a,0,sizeof a);
    a[1]=0;
    a[n]=a[n+1]=1000000000000000000;
    for(int i=1;i<=n/2;i++){
        ll b;
        cin>>b;
        a[n-i+1]=b;
        if(a[n-i+1]>a[n-i+2]){
            ll k = a[n-i+1] - a[n-i+2];
            a[n-i+1]-=k;
            a[i]+=k;
        }
        if(a[i]<a[i-1]){
            ll k = a[i-1] - a[i];
            a[i]+=k;
            a[n-i+1]-=k;
        }
    }
    for(int i=1;i<=n;i++)
        cout<<a[i]<<" ";
}


#include <bits/stdc++.h>
#define ll long long
#define mod 1000000007
using namespace std;
int main() {
   ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin>>n;
    ll b[n/2];
    for(int i=0;i<n/2;i++)
        cin>>b[i];
    ll a[n];
    for(int i=0;i<n;i++)
        a[i]=0ll;
    for(int i=0,j=n-1;i<n/2;i++,j--)
        a[j]=b[i];
    for(int i=n-2;i>=n/2;i--){
        if(a[i]>a[i+1]){
            a[n-i-1]=a[i]-a[i+1];
            a[i]=a[i+1];
        }
    }
    for(int i=0;i<n;i++)
        cout<<a[i]<<" ";
}


#include <bits/stdc++.h>
#define ll long long
#define mod 1000000007
using namespace std;
int main() {
   ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin>>n;
    ll b[n/2];
    for(int i=0;i<n/2;i++)
        cin>>b[i];
    ll a[n];
    for(int i=0;i<n;i++)
        a[i]=0ll;
    for(int i=0,j=n-1;i<n/2;i++,j--)
        a[j]=b[i];
    for(int i=n-2;i>=n/2;i--){
        if(a[i]>a[i+1]){
            a[n-i-1]=a[i]-a[i+1];
            a[i]=a[i+1];
        }
    }
    for(int i=0;i<n/2-1;i++){
        if(a[i]>a[i+1]){
            a[n-i-2] -= (a[i] - a[i+1]);
            a[i+1]=a[i];
        }
    }
    for(int i=0;i<n;i++)
        cout<<a[i]<<" ";
}


#include <bits/stdc++.h>
#define ll long long
#define mod 1000000007
using namespace std;
int main() {
   ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin>>n;
    ll a[n+2];
    memset(a,0,sizeof a);
    a[1]=0;
    a[n]=a[n+1]=1000000000000000000;
    for(int i=1;i<=n/2;i++){
        ll b;
        cin>>b;
        a[n-i+1]=b;
        if(a[n-i+1]>a[n-i+2]){
            ll k = a[n-i+1] - a[n-i+2];
            a[n-i+1]-=k;
            a[i]+=k;
        }
    }
    for(int i=1;i<=n;i++)
        cout<<a[i]<<" ";
}


#include <bits/stdc++.h>
#define ll long long
#define mod 1000000007
using namespace std;
int main() {
   ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin>>n;
    ll b[n/2];
    for(int i=0;i<n/2;i++)
        cin>>b[i];
    ll a[n];
    for(int i=0;i<n;i++)
        a[i]=0ll;
    for(int i=0,j=n-1;i<n/2;i++,j--)
        a[j]=b[i];
    for(int i=n-2;i>=n/2;i--){
        if(a[i]>a[i+1]){
            a[n-i-1]=a[i]-a[i+1];
            a[i]=a[i+1];
        }
    }
    for(int i=0;i<n/2;i++){
        if(a[i]>a[i+1]){
            a[n-i-2] -= (a[i] - a[i+1]);
            a[i+1]=a[i];
        }
    }
    for(int i=0;i<n;i++)
        cout<<a[i]<<" ";
}


#include <bits/stdc++.h>
#define ll long long
#define mod 1000000007
using namespace std;
int main() {
   ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin>>n;
    ll b[n/2+1];
    for(int i=0;i<n/2;i++)
        cin>>b[i];
    ll a[n+1];
    for(int i=0;i<n;i++)
        a[i]=0ll;
    ll prev=0ll, next = b[0];
    a[n-1]=b[0];
    for(int i=1,j=n-2,k=1;k<n/2;i++,j--,k++){
        if(b[k]>next){
            a[j] = next;
            a[i] = prev;
            if(a[i] + a[j] > b[k]){
                a[j] = a[j] - (a[i] + a[j] - b[k]);
            }
            else if(a[i]+a[j]<b[k]){
                a[i] = a[i] + (b[k] - a[i] -a[j]);
            }
        }
        else{
            a[i]=prev;
            a[j]=b[k];
        }
        prev=a[i];
        next=a[j];
    }

    for(int i=0;i<n;i++)
        cout<<a[i]<<" ";
}


#include <bits/stdc++.h>
#define ll long long
#define mod 1000000007
using namespace std;
int main() {
   ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin>>n;
    ll b[n/2+1];
    for(int i=0;i<n/2;i++)
        cin>>b[i];
    ll a[n+1];
    for(int i=0;i<n;i++)
        a[i]=0ll;
    ll prev=1ll, next = b[0];
    a[n-1]=b[0];
    for(int i=1,j=n-2,k=1;k<n/2;i++,j--,k++){
        if(b[k]>next){
            a[j] = next;
            a[i] = prev;
            if(a[i] + a[j] > b[k]){
                a[j] = a[j] - (a[i] + a[j] - b[k]);
            }
            else if(a[i]+a[j]<b[k]){
                a[i] = a[i] + (b[k] - a[i] -a[j]);
            }
        }
        else{
            a[i]=prev;
            a[j]=next;
        }
        prev=a[i];
        next=a[j];
    }

    for(int i=0;i<n;i++)
        cout<<a[i]<<" ";
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
	ll n;
	cin >> n;
	vector<ll> b(n / 2 + 1);
	vector<ll> a(n + 1);
	for(int i = 1; i <= n / 2; i++) {
		cin >> b[i];
	}
	a[n] = b[1];
	a[1] = 0;
	for(int i = 2; i <= n / 2; i++) {
		if (b[i] <= b[i - 1]) {
			a[n - i + 1] = b[i];
			a[i] = 0;
		} else {
			a[n - i + 1] = b[i - 1];
			a[i] = b[i] - b[i - 1];
		}
	}
	for(int i = 1; i <= n; i++) {
		cout << a[i] << " ";
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll unsigned long long
int main() {
//freopen("inp.txt","r",stdin);
	ll n;
	cin >> n;
	vector<ll> b(n / 2 + 1);
	vector<ll> a(n + 1);
	for(int i = 1; i <= n / 2; i++) {
		cin >> b[i];
	}
	a[n] = b[1];
	a[1] = 0;
	for(int i = 2; i <= n / 2; i++) {
		if (b[i] <= min(b[1], b[i - 1])) {
			a[n - i + 1] = b[i];
			a[i] = 0;
		} else {
			a[n - i + 1] = min(b[1], b[i - 1]);
			a[i] = /*(ll)*/b[i] - min(b[1], b[i - 1]);
		}
	}
	for(int i = 1; i <= n; i++) {
		cout << a[i] << " ";
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll unsigned long long
int main() {
	//freopen("inp.txt","r",stdin);
	ll n;
	cin >> n;
	vector<ll> b(n / 2 + 1);
	vector<ll> a(n + 1);
	for(int i = 1; i <= n / 2; i++) {
		cin >> b[i];
	}
	a[n] = b[1];
	a[1] = 0;
	for(int i = 2; i <= n / 2; i++) {
		if (b[i] <= min(b[1], b[i - 1])) {
			a[n - i + 1] = b[i];
			a[i] = 0;
		} else {
			a[n - i + 1] = min(b[1], b[i - 1]);
			a[i] = b[i] - min(b[1], b[i - 1]);
			if (a[i] < a[i - 1]) {
				a[i] = a[i - 1];
				a[n - i + 1] = b[i] - a[i];
			}
		}
	}
	for(int i = 1; i <= n; i++) {
		cout << a[i] << " ";
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll unsigned long long
int main() {
//freopen("inp.txt","r",stdin);
	ll n;
	cin >> n;
	vector<ll> b(n / 2 + 1);
	vector<ll> a(n + 1);
	for(int i = 1; i <= n / 2; i++) {
		cin >> b[i];
	}
	a[n] = b[1];
	a[1] = 0;
	for(int i = 2; i <= n / 2; i++) {
		if (b[i] <= b[1]) {
			a[n - i + 1] = b[i];
			a[i] = 0;
		} else {
			a[n - i + 1] = b[1];
			a[i] = /*(ll)*/b[i] - b[1];
		}
	}
	for(int i = 1; i <= n; i++) {
		cout << a[i] << " ";
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll unsigned long long
int main() {
//freopen("inp.txt","r",stdin);
	ll n;
	cin >> n;
	vector<ll> b(n / 2 + 1);
	vector<ll> a(n + 1);
	for(int i = 1; i <= n / 2; i++) {
		cin >> b[i];
	}
	a[n] = b[1];
	a[1] = 0;
	for(int i = 2; i <= n / 2; i++) {
		if (b[i] <= b[i - 1]) {
			a[n - i + 1] = b[i];
			a[i] = 0;
		} else {
			a[n - i + 1] = b[i - 1];
			a[i] = /*(ll)*/b[i] - b[i - 1];
		}
	}
	for(int i = 1; i <= n; i++) {
		cout << a[i] << " ";
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define int long long
#define vi vector<int>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define pi 3.141592653589793238
#define eb emplace_back
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define zip(i,a,b) for(int i=a;i<b;i++)
#define rzip(i,a,b) for(int i=a;i>=b;i--)
#define ll unsigned int
#define test int t;cin>>t; while(t--)
#define um unordered_map
#define en '\n'
#define us unordered_set
typedef pair<int, int>     pii;
typedef pair<char, int>    pci;
typedef pair<char, char>   pcc;
typedef vector<pii>       vii;
typedef long double ld;
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(),v.rend()
#define sz(x) (int)x.size()
#define INF (1e18+5)
#define inf (1e9+5)
#define mod 1000000007

void __print(int x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
// You should only debug a pair of simple data types. For example,
// the debug won't work if one of pair's elements is collection type
// (std::vector, std::map, std::set...).
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i : x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

// bool check_prime(int n)  return whether a number is prime or not O(sqrt(N));
// int BE(int x,int n,int m)  return x^n%m; O(logN);
// void sieve()  from number 1-1000001 saare prime store kar lega  in bool is_prime[1000001] array
// vector<int> z_array(string s)  return vector which is Z-array of string s;
// vector<int> lps(string s)      return vector which is lps array of string s;
// int power(int x,int n) return x^n; O(logN);
// using_ordered_set (template for using ordered set , replace first 2 lines of this page with this code..);
const int gf = 1e6 + 9;

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(0);
#ifndef ONLINE_JUDGE
	if (fopen("input.txt", "r"))
	{
		freopen ("input.txt" , "r" , stdin);
		freopen ("output.txt" , "w" , stdout);
	}
#endif
	//_______________________________-code starts-_______________________________________________

	int n;
	cin >> n;
	int b[n / 2];
	zip(i, 0, n / 2)
	{
		cin >> b[i];
	}
	vi v;
	v.pb(0ll);
	int r = b[0];
	int l = 0;
	zip(i, 1, n / 2)
	{
		if (b[i] <= r)
		{
			//int x = v[sz(v) - 1];
			v.pb(l);
			//l = x;
			r = b[i] - l;
		}
		else if (b[i] > r)
		{
			int extra = b[i] - r;
			int x = b[i] - r;
			//v.pb(x);
			// l = x;
			// r = b[i] - x;
			if (x < v[sz(v) - 1])
			{
				int dif = v[sz(v) - 1] - x;
				x += diff;

			}
			l = x;
			r = b[i] - x;
		}
	}
	vi v1;
	// zip(i, 0, n / 2)
	// {
	// 	v1.pb(b[i] - v[n / 2 - i - 1]);
	// }
	zip(i, 0, n / 2)cout << v[i] << " ";
	zip(i, 0, n / 2)cout << b[n / 2 - i - 1] - v[n / 2 - i - 1] << " ";

	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define int long long
#define vi vector<int>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define pi 3.141592653589793238
#define eb emplace_back
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define zip(i,a,b) for(int i=a;i<b;i++)
#define rzip(i,a,b) for(int i=a;i>=b;i--)
#define ll unsigned int
#define test int t;cin>>t; while(t--)
#define um unordered_map
#define en '\n'
#define us unordered_set
typedef pair<int, int>     pii;
typedef pair<char, int>    pci;
typedef pair<char, char>   pcc;
typedef vector<pii>       vii;
typedef long double ld;
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(),v.rend()
#define sz(x) (int)x.size()
#define INF (1e18+5)
#define inf (1e9+5)
#define mod 1000000007

void __print(int x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
// You should only debug a pair of simple data types. For example,
// the debug won't work if one of pair's elements is collection type
// (std::vector, std::map, std::set...).
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i : x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

// bool check_prime(int n)  return whether a number is prime or not O(sqrt(N));
// int BE(int x,int n,int m)  return x^n%m; O(logN);
// void sieve()  from number 1-1000001 saare prime store kar lega  in bool is_prime[1000001] array
// vector<int> z_array(string s)  return vector which is Z-array of string s;
// vector<int> lps(string s)      return vector which is lps array of string s;
// int power(int x,int n) return x^n; O(logN);
// using_ordered_set (template for using ordered set , replace first 2 lines of this page with this code..);
const int gf = 1e6 + 9;

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(0);
#ifndef ONLINE_JUDGE
	if (fopen("input.txt", "r"))
	{
		freopen ("input.txt" , "r" , stdin);
		freopen ("output.txt" , "w" , stdout);
	}
#endif
	//_______________________________-code starts-_______________________________________________

	int n;
	cin >> n;
	int b[n / 2];
	zip(i, 0, n / 2)
	{
		cin >> b[i];
	}
	// b[i]=a[i]+a[n-i-1]..
	//
	vi v;
	v.pb(0ll);
	int r = b[0];
	int l = 0;
	zip(i, 1, n / 2)
	{
		if (b[i] <= r)
		{
			int x = v[sz(v) - 1];
			v.pb(x);
			l = x;
			r = b[i] - x;
		}
		else if (b[i] > r)
		{
			int extra = b[i] - r;
			int x = b[i] - r;
			v.pb(x);
			l = x;
			r = b[i] - x;
		}
	}
	vi v1;
	// zip(i, 0, n / 2)
	// {
	// 	v1.pb(b[i] - v[n / 2 - i - 1]);
	// }
	zip(i, 0, n / 2)cout << v[i] << " ";
	zip(i, 0, n / 2)cout << b[n / 2 - i - 1] - v[n / 2 - i - 1] << " ";

	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define int long long
#define vi vector<int>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define pi 3.141592653589793238
#define eb emplace_back
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define zip(i,a,b) for(int i=a;i<b;i++)
#define rzip(i,a,b) for(int i=a;i>=b;i--)
#define ll unsigned int
#define test int t;cin>>t; while(t--)
#define um unordered_map
#define en '\n'
#define us unordered_set
typedef pair<int, int>     pii;
typedef pair<char, int>    pci;
typedef pair<char, char>   pcc;
typedef vector<pii>       vii;
typedef long double ld;
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(),v.rend()
#define sz(x) (int)x.size()
#define INF (1e18+5)
#define inf (1e9+5)
#define mod 1000000007

void __print(int x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
// You should only debug a pair of simple data types. For example,
// the debug won't work if one of pair's elements is collection type
// (std::vector, std::map, std::set...).
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i : x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

// bool check_prime(int n)  return whether a number is prime or not O(sqrt(N));
// int BE(int x,int n,int m)  return x^n%m; O(logN);
// void sieve()  from number 1-1000001 saare prime store kar lega  in bool is_prime[1000001] array
// vector<int> z_array(string s)  return vector which is Z-array of string s;
// vector<int> lps(string s)      return vector which is lps array of string s;
// int power(int x,int n) return x^n; O(logN);
// using_ordered_set (template for using ordered set , replace first 2 lines of this page with this code..);
const int gf = 1e6 + 9;

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(0);
#ifndef ONLINE_JUDGE
	if (fopen("input.txt", "r"))
	{
		freopen ("input.txt" , "r" , stdin);
		freopen ("output.txt" , "w" , stdout);
	}
#endif
	//_______________________________-code starts-_______________________________________________

	int n;
	cin >> n;
	int b[n / 2];
	zip(i, 0, n / 2)
	{
		cin >> b[i];
	}
	vi v;
	v.pb(0ll);
	int r = b[0];
	int l = 0;
	zip(i, 1, n / 2)
	{
		if (b[i] <= r)
		{
			//int x = v[sz(v) - 1];
			v.pb(l);
			//l = x;
			r = b[i] - l;
		}
		else if (b[i] > r)
		{
			int extra = b[i] - r;
			int x = b[i] - r;
			//v.pb(x);
			// l = x;
			// r = b[i] - x;
			if (x < v[sz(v) - 1])
			{
				int dif = v[sz(v) - 1] - x;
				x += dif;
			}
			l = x;
			r = b[i] - x;
			v.pb(x);
		}
	}
	vi v1;
	// zip(i, 0, n / 2)
	// {
	// 	v1.pb(b[i] - v[n / 2 - i - 1]);
	// }
	zip(i, 0, n / 2)cout << v[i] << " ";
	zip(i, 0, n / 2)cout << b[n / 2 - i - 1] - v[n / 2 - i - 1] << " ";

	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define int long long
#define vi vector<int>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define pi 3.141592653589793238
#define eb emplace_back
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define zip(i,a,b) for(int i=a;i<b;i++)
#define rzip(i,a,b) for(int i=a;i>=b;i--)
#define ll unsigned int
#define test int t;cin>>t; while(t--)
#define um unordered_map
#define en '\n'
#define us unordered_set
typedef pair<int, int>     pii;
typedef pair<char, int>    pci;
typedef pair<char, char>   pcc;
typedef vector<pii>       vii;
typedef long double ld;
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(),v.rend()
#define sz(x) (int)x.size()
#define INF (1e18+5)
#define inf (1e9+5)
#define mod 1000000007

void __print(int x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
// You should only debug a pair of simple data types. For example,
// the debug won't work if one of pair's elements is collection type
// (std::vector, std::map, std::set...).
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i : x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

// bool check_prime(int n)  return whether a number is prime or not O(sqrt(N));
// int BE(int x,int n,int m)  return x^n%m; O(logN);
// void sieve()  from number 1-1000001 saare prime store kar lega  in bool is_prime[1000001] array
// vector<int> z_array(string s)  return vector which is Z-array of string s;
// vector<int> lps(string s)      return vector which is lps array of string s;
// int power(int x,int n) return x^n; O(logN);
// using_ordered_set (template for using ordered set , replace first 2 lines of this page with this code..);
const int gf = 1e6 + 9;

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(0);
#ifndef ONLINE_JUDGE
	if (fopen("input.txt", "r"))
	{
		freopen ("input.txt" , "r" , stdin);
		freopen ("output.txt" , "w" , stdout);
	}
#endif
	//_______________________________-code starts-_______________________________________________

	int n;
	cin >> n;
	int b[n / 2];
	zip(i, 0, n / 2)
	{
		cin >> b[i];
	}
	vi v;
	v.pb(0ll);
	int r = b[0];
	int l = 0;
	zip(i, 1, n / 2)
	{
		if (b[i] <= r && b[i] >= l)
		{
			int x = v[sz(v) - 1];
			v.pb(x);
			l = x;
			r = b[i] - x;
		}
		else if (b[i] < l)
		{
			v.pb(l);
		}
		else if (b[i] > r)
		{
			int extra = b[i] - r;
			int x = b[i] - r;
			v.pb(x);
			l = x;
			r = b[i] - x;
		}
	}
	vi v1;
	// zip(i, 0, n / 2)
	// {
	// 	v1.pb(b[i] - v[n / 2 - i - 1]);
	// }
	zip(i, 0, n / 2)cout << v[i] << " ";
	zip(i, 0, n / 2)cout << b[n / 2 - i - 1] - v[n / 2 - i - 1] << " ";

	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define int long long
#define vi vector<int>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define pi 3.141592653589793238
#define eb emplace_back
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define zip(i,a,b) for(int i=a;i<b;i++)
#define rzip(i,a,b) for(int i=a;i>=b;i--)
#define ll unsigned int
#define test int t;cin>>t; while(t--)
#define um unordered_map
#define en '\n'
#define us unordered_set
typedef pair<int, int>     pii;
typedef pair<char, int>    pci;
typedef pair<char, char>   pcc;
typedef vector<pii>       vii;
typedef long double ld;
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(),v.rend()
#define sz(x) (int)x.size()
#define INF (1e18+5)
#define inf (1e9+5)
#define mod 1000000007

void __print(int x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
// You should only debug a pair of simple data types. For example,
// the debug won't work if one of pair's elements is collection type
// (std::vector, std::map, std::set...).
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i : x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

// bool check_prime(int n)  return whether a number is prime or not O(sqrt(N));
// int BE(int x,int n,int m)  return x^n%m; O(logN);
// void sieve()  from number 1-1000001 saare prime store kar lega  in bool is_prime[1000001] array
// vector<int> z_array(string s)  return vector which is Z-array of string s;
// vector<int> lps(string s)      return vector which is lps array of string s;
// int power(int x,int n) return x^n; O(logN);
// using_ordered_set (template for using ordered set , replace first 2 lines of this page with this code..);
const int gf = 1e6 + 9;

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(0);
#ifndef ONLINE_JUDGE
	if (fopen("input.txt", "r"))
	{
		freopen ("input.txt" , "r" , stdin);
		freopen ("output.txt" , "w" , stdout);
	}
#endif
	//_______________________________-code starts-_______________________________________________

	int n;
	cin >> n;
	int b[n / 2];
	zip(i, 0, n / 2)
	{
		cin >> b[i];
	}
	// b[i]=a[i]+a[n-i-1]..
	//
	vi v;
	v.pb(0ll);
	int r = b[0];
	int l = 0;
	zip(i, 1, n / 2)
	{
		if (b[i] <= r)
		{
			int x = v[sz(v) - 1];
			v.pb(x);
			l = x;
			r = b[i];
		}
		else if (b[i] > r)
		{
			int extra = b[i] - r;
			int x = b[i] - r;
			v.pb(x);
			l = x;
			r = b[i] - x;
		}
	}
	vi v1;
	// zip(i, 0, n / 2)
	// {
	// 	v1.pb(b[i] - v[n / 2 - i - 1]);
	// }
	zip(i, 0, n / 2)cout << v[i] << " ";
	zip(i, 0, n / 2)cout << b[n / 2 - i - 1] - v[n / 2 - i - 1] << " ";

	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define int long long
#define vi vector<int>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define pi 3.141592653589793238
#define eb emplace_back
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define zip(i,a,b) for(int i=a;i<b;i++)
#define rzip(i,a,b) for(int i=a;i>=b;i--)
#define ll unsigned int
#define test int t;cin>>t; while(t--)
#define um unordered_map
#define en '\n'
#define us unordered_set
typedef pair<int, int>     pii;
typedef pair<char, int>    pci;
typedef pair<char, char>   pcc;
typedef vector<pii>       vii;
typedef long double ld;
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(),v.rend()
#define sz(x) (int)x.size()
#define INF (1e18+5)
#define inf (1e9+5)
#define mod 1000000007

void __print(int x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
// You should only debug a pair of simple data types. For example,
// the debug won't work if one of pair's elements is collection type
// (std::vector, std::map, std::set...).
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i : x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

// bool check_prime(int n)  return whether a number is prime or not O(sqrt(N));
// int BE(int x,int n,int m)  return x^n%m; O(logN);
// void sieve()  from number 1-1000001 saare prime store kar lega  in bool is_prime[1000001] array
// vector<int> z_array(string s)  return vector which is Z-array of string s;
// vector<int> lps(string s)      return vector which is lps array of string s;
// int power(int x,int n) return x^n; O(logN);
// using_ordered_set (template for using ordered set , replace first 2 lines of this page with this code..);
const int gf = 1e6 + 9;

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(0);
#ifndef ONLINE_JUDGE
	if (fopen("input.txt", "r"))
	{
		freopen ("input.txt" , "r" , stdin);
		freopen ("output.txt" , "w" , stdout);
	}
#endif
	//_______________________________-code starts-_______________________________________________

	int n;
	cin >> n;
	int b[n / 2];
	zip(i, 0, n / 2)
	{
		cin >> b[i];
	}
	// b[i]=a[i]+a[n-i-1]..
	//
	vi v;
	v.pb(0ll);
	int r = b[0];
	int l = 0;
	zip(i, 1, n / 2)
	{
		if (b[i] <= r)
		{
			int x = v[sz(v) - 1];
			v.pb(x);
			l = x;
			r = b[i];
		}
		else if (b[i] > r)
		{
			int extra = b[i] - r;
			int x = b[i] - r;
			v.pb(x);
			l = x;
			r = b[i] - x;
		}
	}
	vi v1;
	zip(i, 0, n / 2)
	{
		v1.pb(b[i] - v[n / 2 - i - 1]);
	}
	zip(i, 0, n / 2)cout << v[i] << " ";
	zip(i, 0, n / 2)cout << v1[i] << " ";

	return 0;
}


#include "bits/stdc++.h"
using namespace std;
typedef  long long ll ;
typedef vector<ll> ve ;
typedef pair <int , int> pr ;
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define MAX INT_MAX
#define MIN (-1 * INT_MAX)
#define rep(i,a,b) for(ll i = a ; i< b ; ++i)
#define repp(i,a,b) for( i = a ; i< b ; ++i)
#define loop(i , arr)  for(auto i : arr)
#define endl '\n'
ve    vec  , vec2  , vec3  , vec4 , v , p;
ll t , n , k , sum , cnt;
priority_queue<ll> pq ;
map< ll , ll> mp ,  mpp ,mpc ;
//string s1 ;
bool sortBySec(const pair<int,int> &a,
               const pair<int,int> &b)
{
    return (a.second >= b.second);
}
const int mod = 1e9+7 ;
char ch[100001];
const int sss = 1e5+1 ;
const int sss2 = 1e5+2 ;
int arrr[sss2] = {0} ;
vector <int> alls(6) ;
map<string , int> mps ;
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
   cin >> n ;
    int arr[n] ;
    memset(arr ,0 , sizeof(arr)) ;
    sum = 0 ;
   rep(i , 0 , n/2) {int xx  ; cin>>xx ; sum+=xx ; }
   arr[n-1] = sum ;
   rep(i , 0 , n) cout << arr[i] <<" " ;
}


#include "bits/stdc++.h"
using namespace std;
typedef  long long ll ;
typedef vector<ll> ve ;
typedef pair <int , int> pr ;
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define MAX INT_MAX
#define MIN (-1 * INT_MAX)
#define rep(i,a,b) for(ll i = a ; i< b ; ++i)
#define repp(i,a,b) for( int i = a ; i< b ; i+=2)
#define loop(i , arr)  for(auto i : arr)
#define endl '\n'
ve    vec  , vec2  , vec3  , vec4 , v , p;
ll t , n , k , sum , cnt;
priority_queue<ll> pq ;
map< ll , ll> mp ,  mpp ,mpc ;
//string s1 ;
bool sortBySec(const pair<int,int> &a,
               const pair<int,int> &b)
{
    return (a.second >= b.second);
}
const int mod = 1e9+7 ;
char ch[100001];
const int sss = 1e5+1 ;
const int sss2 = 1e5+2 ;
int arrr[sss2] = {0} ;
vector <int> alls(6) ;
map<string , int> mps ;
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
   cin >> n ;
    int arr[n] ;
    memset(arr ,0 , sizeof(arr)) ;
     vec2.resize(n)  ;
     rep(i, 0 , n/2){
         int xx ;
         cin >>xx ;
         vec.PB(xx) ;
     }
     k = 0 ;
     fill(vec2.begin() , vec2.end() , 0);
    repp(i, 0 , n-1){
        if (vec[k]>=2) {
            vec2[i] = vec[k] / 2;
            vec2[i + 1] = (vec[k] / 2) + (vec[k] % 2);
        }else{
            vec2[i] = vec[i] ;
            i-- ;
        }
        k++ ;
    }
    sort(vec2.begin() , vec2.end());
    rep(i , 0 , n) cout <<vec2[i] <<" " ;

}


#include "bits/stdc++.h"
using namespace std;
typedef  long long ll ;
typedef vector<ll> ve ;
typedef pair <int , int> pr ;
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define MAX INT_MAX
#define MIN (-1 * INT_MAX)
#define rep(i,a,b) for(ll i = a ; i< b ; ++i)
#define repp(i,a,b) for( int i = a ; i< b ; i+=2)
#define loop(i , arr)  for(auto i : arr)
#define endl '\n'
ve    vec  , vec2  , vec3  , vec4 , v , p;
ll t , n , k , sum , cnt;
priority_queue<ll> pq ;
map< ll , ll> mp ,  mpp ,mpc ;
//string s1 ;
bool sortBySec(const pair<int,int> &a,
               const pair<int,int> &b)
{
    return (a.second >= b.second);
}
const int mod = 1e9+7 ;
char ch[100001];
const int sss = 1e5+1 ;
const int sss2 = 1e5+2 ;
int arrr[sss2] = {0} ;
vector <int> alls(6) ;
map<string , int> mps ;
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
   cin >> n ;
    int arr[n] ;
    memset(arr ,0 , sizeof(arr)) ;
     vec2.resize(n)  ;
     rep(i, 0 , n/2){
         int xx ;
         cin >>xx ;
         vec.PB(xx) ;
     }
     k = 0 ;
     fill(vec2.begin() , vec2.end() , 0);
    repp(i, 0 , n-1){
        if (vec[k]>=2) {
            vec2[i] = vec[k] / 2;
            vec2[i + 1] = (vec[k] / 2) + (vec[k] % 2);
        }else{
            vec2[i] = vec[k] ;
         }
        k++ ;
    }
    sort(vec2.begin() , vec2.end());
    rep(i , 0 , n) cout <<vec2[i] <<" " ;

}


#include "bits/stdc++.h"
using namespace std;
typedef  long long ll ;
typedef vector<ll> ve ;
typedef pair <int , int> pr ;
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define MAX INT_MAX
#define MIN (-1 * INT_MAX)
#define rep(i,a,b) for(ll i = a ; i< b ; ++i)
#define repp(i,a,b) for( int i = a ; i< b ; i+=2)
#define loop(i , arr)  for(auto i : arr)
#define endl '\n'
ve    vec  , vec2  , vec3  , vec4 , v , p;
ll t , n , k , sum , cnt;
priority_queue<ll> pq ;
map< ll , ll> mp ,  mpp ,mpc ;
//string s1 ;
bool sortBySec(const pair<int,int> &a,
               const pair<int,int> &b)
{
    return (a.second >= b.second);
}
const int mod = 1e9+7 ;
char ch[100001];
const int sss = 1e5+1 ;
const int sss2 = 1e5+2 ;
int arrr[sss2] = {0} ;
vector <int> alls(6) ;
map<string , int> mps ;
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
   cin >> n ;
    int arr[n] ;
    memset(arr ,0 , sizeof(arr)) ;
     vec2.resize(n)  ;
     rep(i, 0 , n/2){
         int xx ;
         cin >>xx ;
         vec.PB(xx) ;
     }
     k = 0 ;
    repp(i, 0 , n){
        if (vec[k]>=2) {
            vec2[i] = vec[k] / 2;
            vec2[i + 1] = (vec[k] / 2) + (vec[k] % 2);
        }else{
            vec2[i] = vec[i] ;
            i-- ;
        }
        k++ ;
    }
    sort(vec2.begin() , vec2.end());
    rep(i , 0 , n) cout <<vec2[i] <<" " ;

}


#include "bits/stdc++.h"
using namespace std;
typedef  long long ll ;
typedef vector<ll> ve ;
typedef pair <int , int> pr ;
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define MAX INT_MAX
#define MIN (-1 * INT_MAX)
#define rep(i,a,b) for(ll i = a ; i< b ; ++i)
#define repp(i,a,b) for( int i = a ; i< b ; i+=2)
#define loop(i , arr)  for(auto i : arr)
#define endl '\n'
ve    vec  , vec2  , vec3  , vec4 , v , p;
ll t , n , k , sum , cnt;
priority_queue<ll> pq ;
map< ll , ll> mp ,  mpp ,mpc ;
//string s1 ;
bool sortBySec(const pair<int,int> &a,
               const pair<int,int> &b)
{
    return (a.second >= b.second);
}
const int mod = 1e9+7 ;
char ch[100001];
const int sss = 1e5+1 ;
const int sss2 = 1e5+2 ;
int arrr[sss2] = {0} ;
vector <int> alls(6) ;
map<string , int> mps ;
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
   cin >> n ;
    int arr[n] ;
    memset(arr ,0 , sizeof(arr)) ;
     vec2.resize(n)  ;
     rep(i, 0 , n/2){
         int xx ;
         cin >>xx ;
         vec.PB(xx) ;
     }
     k = 0 ;
     fill(vec2.begin() , vec2.end() , 0);
    repp(i, 0 , n){
        if (vec[k]>=2) {
            vec2[i] = vec[k] / 2;
            vec2[i + 1] = (vec[k] / 2) + (vec[k] % 2);
        }else{
            vec2[i] = vec[i] ;
            i-- ;
        }
        k++ ;
    }
    sort(vec2.begin() , vec2.end());
    rep(i , 0 , n) cout <<vec2[i] <<" " ;

}


#include "bits/stdc++.h"
using namespace std;
typedef  long long ll ;
typedef vector<ll> ve ;
typedef pair <int , int> pr ;
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define MAX INT_MAX
#define MIN (-1 * INT_MAX)
#define rep(i,a,b) for(ll i = a ; i< b ; ++i)
#define repp(i,a,b) for(  i = a ; i< b ; i++)
#define loop(i , arr)  for(auto i : arr)
#define endl '\n'
ve    vec  , vec2  , vec3  , vec4 , v , p;
ll t , n , k , sum , cnt;
priority_queue<ll> pq ;
map< ll , ll> mp ,  mpp ,mpc ;
//string s1 ;
bool sortBySec(const pair<int,int> &a,
               const pair<int,int> &b)
{
    return (a.second >= b.second);
}
const int mod = 1e9+7 ;
char ch[100001];
const int sss = 1e5+1 ;
const int sss2 = 1e5+2 ;
int arrr[sss2] = {0} ;
vector <int> alls(6) ;
map<string , int> mps ;
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
   cin >> n ;
    int arr[n] ;
    memset(arr ,0 , sizeof(arr)) ;
     vec2.resize(n)  ;
     fill(vec2.begin() , vec2.end() , 0) ;
     int l = n ;
     rep(i, 0 , n/2){
         ll xx ;
         cin >>xx ;
         if(i == 0 ){
             vec2[0] =  0 ;
             vec2[n-1] = xx ;
             continue;
         }
        if (vec2[n - i] <  xx - vec2[n-i])
         vec2[i] = max(vec2[i-1] , vec2[n-i]) ;
        else
            vec2[i] = max(vec2[i-1] , xx-vec2[n-i]) ;

        vec2[n-1-i] = xx - vec2[i] ;
     }
     rep(i , 0 , n) cout << vec2[i] <<" " ;

}


#include <bits/stdc++.h>

using namespace std;

int main() {

	unsigned int n;
	cin >> n;

	unsigned long long int b[n/2],a[n];

	for(int i = 0; i*2 < n; i++){
		cin >> b[i];
	}

	unsigned long long int diff;

	a[0] = 0;
	a[n-1] = b[0];

	for(unsigned long long int i = 1; i*2 < n; i++){

		a[n-i-1] = min(b[i],a[n-i]);
		a[i]     = b[i] - a[n-i-1];

		if(a[i] < a[i-1]){
			diff = a[i-1] - a[i];
			a[i] += diff;
			a[n-i-1] -= diff;
		}

	}

	for(unsigned long long int i = 0; i < n; i++) cout << a[i] << " ";
	cout << endl;

	return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main() {

	unsigned int n;
	cin >> n;

	int b[n/2],a[n];

	for(int i = 0; i*2 < n; i++){
		cin >> b[i];
	}

	a[0] = 0;
	a[n-1] = b[0];

	for(int i = 1; i*2 < n; i++){

		a[n-i-1] = min(b[i],a[n-i]);
		a[i]     = b[i] - a[n-i-1];

		if(a[i] < a[i-1]){
			int diff = a[i-1] - a[i];
			a[i] += diff;
			a[n-i-1] -= diff;
		}

	}

	for(int i = 0; i < n; i++) cout << a[i] << " ";
	cout << endl;

	return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define endl '\n'

int main() {

	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0)

	unsigned int n;
	cin >> n;

	unsigned long long int b[n/2],a[n];

	for(int i = 0; i*2 < n; i++){
		cin >> b[i];
	}

	unsigned long long int diff;

	a[0] = 0;
	a[n-1] = b[0];

	for(unsigned long long int i = 1; i*2 < n; i++){

		a[n-i-1] = min(b[i],a[n-i]);
		a[i]     = b[i] - a[n-i-1];

		if(a[i] < a[i-1]){
			diff = a[i-1] - a[i];
			a[i] += diff;
			a[n-i-1] -= diff;
		}

	}

	for(unsigned long long int i = 0; i < n; i++) cout << a[i] << " ";
	cout << endl;

	return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define endl '\n'
#define ll    long long int

int main() {

	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);

	ll n;
	cin >> n;

	ll b[n/2],a[n];
	int limit = n/2;

	for(int i = 0; i < limit; i++){
		cin >> b[i];
	}

	ll diff;

	a[0] = 0;
	a[n-1] = b[0];

	for(int i = 1; i < limit; i++){

		a[n-i-1] = min(b[i],a[n-i]);
		a[i]     = b[i] - a[n-i-1];

		if(a[i] < a[i-1]){
			diff = a[i-1] - a[i];
			a[i] += diff;
			a[n-i-1] -= diff;
		}

	}

	for(ll i = 0; i < n; i++) cout << a[i] << " ";
	cout << endl;

	return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define endl '\n'

int main() {

	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);

	unsigned int n;
	cin >> n;

	unsigned long long int b[n/2],a[n];

	for(int i = 0; i*2 < n; i++){
		cin >> b[i];
	}

	unsigned long long int diff;

	a[0] = 0;
	a[n-1] = b[0];

	for(unsigned long long int i = 1; i*2 < n; i++){

		a[n-i-1] = min(b[i],a[n-i]);
		a[i]     = b[i] - a[n-i-1];

		if(a[i] < a[i-1]){
			diff = a[i-1] - a[i];
			a[i] += diff;
			a[n-i-1] -= diff;
		}

	}

	for(unsigned long long int i = 0; i < n; i++) cout << a[i] << " ";
	cout << endl;

	return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main() {

	unsigned int n;
	cin >> n;

	int b[n/2],a[n];

	for(int i = 0; i*2 < n; i++){
		cin >> b[i];
	}

	a[0] = 0;
	a[n-1] = b[0];

	for(int i = 1; i*22< n; i++){
		if(b[i] >= a[n-i]){
			a[n-i-1] =  a[n-i];
			a[i]     =  b[i]-a[n-i-1];
		}else{
			a[i]     = a[i-1];
			a[n-i-1] = b[i] - a[i];
		}
	}

	for(int i = 0; i < n; i++) cout << a[i] << " ";
	cout << endl;

	return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main() {

	unsigned int n;
	cin >> n;

	int b[n/2],a[n];

	for(int i = 0; i*2 < n; i++){
		cin >> b[i];
	}

	a[0] = 0;
	a[n-1] = b[0];

	for(int i = 1; i*i < n; i++){
		if(b[i] >= a[n-i]){
			a[n-i-1] =  a[n-i];
			a[i]     =  b[i]-a[n-i-1];
		}else{
			a[i]     = a[i-1];
			a[n-i-1] = b[i] - a[i];
		}
	}

	for(int i = 0; i < n; i++) cout << a[i] << " ";
	cout << endl;

	return 0;
}


#include<iostream>
#include<stdio.h>
#include<string.h>
#include<queue>
using namespace std;
#define ll long long
const int maxn=200005;
const ll inf=10000000000000000;
int head[maxn];
int nxt[500005];
int to[500005];
ll w[500005];
ll dis[maxn];
int tot=0;
bool vis[maxn];
struct node{
	int u;
	ll dd;
	node(){}
	node(int a,int b):u(a),dd(b){}
	bool operator <(const node& c)const{
		return dd>c.dd;
	}
};

void add(int u,int v,ll ww)
{
	tot++;
	nxt[tot]=head[u];
	head[u]=tot;
	to[tot]=v;
	w[tot]=ww;
}
void init(int n)
{
	memset(head,-1,sizeof(head));
	for(int i=0;i<=n;i++)
		dis[i]=inf;
	tot=0;
}
void dij(int s)
{
	int u=s;
	dis[u]=0;
	priority_queue<node>q;
	q.push(node(0,dis[u]));
	while(!q.empty())
	{
		u=q.top().u;
		ll disu=q.top().dd;
		q.pop();
		if(vis[u])
			continue;
		vis[u]=1;

		for(int i=head[u];i!=-1;i=nxt[i])
		{
			int v=to[i];
			if(dis[v]>disu+w[i])
			{
				dis[v]=disu+w[i];
				q.push(node(v,dis[v]));
			}
		}
	}
}

int main()
{
	int n,m;
	scanf("%d %d",&n,&m);
	init(n);int u,v;ll ww;
	for(int i=1;i<=m;i++)
	{
		scanf("%d %d %I64d",&u,&v,&ww);
		add(u,v,1ll*2*ww);
		add(v,u,1ll*2*ww);
	}
	ll t;
	for(int i=1;i<=n;i++)//super
	{
		scanf("%I64d",&t);
		add(0,i,t);
	}
	dij(0);
	printf("%I64d",dis[1]);
	for(int i=2;i<=n;i++)
		printf(" %I64d",dis[i]);
	printf("\n");
}


#include<iostream>
#include<stdio.h>
#include<string.h>
#include<queue>
using namespace std;
#define ll long long
const int maxn=200005;
const ll inf=(1ll<<60)-1;
int head[maxn];
int nxt[600005];
int to[600005];
ll w[600005];
ll dis[maxn];
int tot=0;
bool vis[maxn];
struct node{
	int u;
	ll dd;
	node(){}
	node(int a,ll b):u(a),dd(b){}
	bool operator <(const node& c)const{
		return dd>c.dd;
	}
};

void add(int u,int v,ll ww)
{
	tot++;
	nxt[tot]=head[u];
	head[u]=tot;
	to[tot]=v;
	w[tot]=ww;
}
void init(int n)
{
	//memset(head,-1,sizeof(head));
	for(int i=0;i<=n;i++)
		dis[i]=inf,vis[i]=0,head[i]=-1;
	tot=0;
}
void dij(int s)
{
	int u=s;
	dis[u]=0;
	priority_queue<node>q;
	q.push(node(0,dis[u]));
	while(!q.empty())
	{
		u=q.top().u;
		ll disu=q.top().dd;
		q.pop();
		if(vis[u])
			continue;
		vis[u]=1;

		for(int i=head[u];i!=-1;i=nxt[i])
		{
			int v=to[i];
			if(dis[v]>disu+w[i])
			{
				dis[v]=disu+w[i];
				q.push(node(v,dis[v]));
			}
		}
	}
}

int main()
{
	int n,m;
	scanf("%d %d",&n,&m);
	init(n);int u,v;ll ww;
	for(int i=1;i<=m;i++)
	{
		scanf("%d %d %I64d",&u,&v,&ww);
		add(u,v,1ll*2*ww);
		add(v,u,1ll*2*ww);
	}
	ll t;
	for(int i=1;i<=n;i++)//super
	{
		scanf("%I64d",&t);
		add(0,i,t);
	}
	dij(0);
	printf("%I64d",dis[1]);
	for(int i=2;i<=n;i++)
		printf(" %I64d",dis[i]);
	printf("\n");
}


#include<iostream>
#include<stdio.h>
#include<string.h>
#include<queue>
using namespace std;
#define ll long long
const int maxn=200005;
const ll inf=(1ll<<60)-1;
int head[maxn];
int nxt[600005];
int to[600005];
ll w[600005];
ll dis[maxn];
int tot=0;
bool vis[maxn];
struct node{
	int u;
	ll dd;
	node(){}
	node(int a,int b):u(a),dd(b){}
	bool operator <(const node& c)const{
		return dd>c.dd;
	}
};

void add(int u,int v,ll ww)
{
	tot++;
	nxt[tot]=head[u];
	head[u]=tot;
	to[tot]=v;
	w[tot]=ww;
}
void init(int n)
{
	//memset(head,-1,sizeof(head));
	for(int i=0;i<=n;i++)
		dis[i]=inf,vis[i]=0,head[i]=-1;
	tot=0;
}
void dij(int s)
{
	int u=s;
	dis[u]=0;
	priority_queue<node>q;
	q.push(node(0,dis[u]));
	while(!q.empty())
	{
		u=q.top().u;
		ll disu=q.top().dd;
		q.pop();
		if(vis[u])
			continue;
		vis[u]=1;

		for(int i=head[u];i!=-1;i=nxt[i])
		{
			int v=to[i];
			if(!vis[v]&&dis[v]>disu+w[i])
			{
				dis[v]=disu+w[i];
				q.push(node(v,dis[v]));
			}
		}
	}
}

int main()
{
	int n,m;
	scanf("%d %d",&n,&m);
	init(n);int u,v;ll ww;
	for(int i=1;i<=m;i++)
	{
		scanf("%d %d %I64d",&u,&v,&ww);
		add(u,v,1ll*2*ww);
		add(v,u,1ll*2*ww);
	}
	ll t;
	for(int i=1;i<=n;i++)//super
	{
		scanf("%I64d",&t);
		add(0,i,t);
	}
	dij(0);
	printf("%I64d",dis[1]);
	for(int i=2;i<=n;i++)
		printf(" %I64d",dis[i]);
	printf("\n");
}


#include<iostream>
#include<stdio.h>
#include<string.h>
#include<queue>
using namespace std;
#define ll long long
const int maxn=200005;
const ll inf=(1ll<<60)-1;
int head[maxn];
int nxt[600005];
int to[600005];
ll w[600005];
ll dis[maxn];
int tot=0;
bool vis[maxn];
struct node{
	int u;
	ll dd;
	node(){}
	node(int a,ll b):u(a),dd(b){}
	bool operator <(const node& c)const{
		return dd>c.dd;
	}
};

void add(int u,int v,ll ww)
{
	tot++;
	nxt[tot]=head[u];
	head[u]=tot;
	to[tot]=v;
	w[tot]=ww;
}
void init(int n)
{
	memset(head,-1,sizeof(head));
	for(int i=0;i<=n;i++)
		dis[i]=inf,vis[i]=0,head[i]=-1;
	tot=0;
}
void dij(int s)
{
	int u=s;
	dis[u]=0;
	priority_queue<node>q;
	q.push(node(0,dis[u]));
	while(!q.empty())
	{
		u=q.top().u;
		ll disu=q.top().dd;
		q.pop();
		if(vis[u])
			continue;
		vis[u]=1;

		for(int i=head[u];i!=-1;i=nxt[i])
		{
			int v=to[i];
			if(dis[v]>disu+w[i])
			{
				dis[v]=disu+w[i];
				q.push(node(v,dis[v]));
			}
		}
	}
}

int main()
{
	int n,m;
	scanf("%d %d",&n,&m);
	init(n);int u,v;ll ww;
	for(int i=1;i<=m;i++)
	{
		scanf("%d %d %I64d",&u,&v,&ww);
		add(u,v,1ll*2*ww);
		add(v,u,1ll*2*ww);
	}
	ll t;
	for(int i=1;i<=n;i++)//super
	{
		scanf("%I64d",&t);
		add(0,i,t);
	}
	dij(0);
	printf("%I64d",dis[1]);
	for(int i=2;i<=n;i++)
		printf(" %I64d",dis[i]);
	printf("\n");
}


#include<iostream>
#include<stdio.h>
#include<string.h>
#include<queue>
using namespace std;
#define ll long long
const int maxn=200005;
const ll inf=0x3f3f3f3f3f3f3f3f;
int head[maxn];
int nxt[500005];
int to[500005];
ll w[500005];
ll dis[maxn];
int tot=0;
bool vis[maxn];
struct node{
	int u;
	ll dd;
	node(){}
	node(int a,int b):u(a),dd(b){}
	bool operator <(const node& c)const{
		return dd>c.dd;
	}
};

void add(int u,int v,ll ww)
{
	tot++;
	nxt[tot]=head[u];
	head[u]=tot;
	to[tot]=v;
	w[tot]=ww;
}
void init(int n)
{
	memset(head,-1,sizeof(head));
	for(int i=0;i<=n;i++)
		dis[i]=inf;
	tot=0;
}
void dij(int s)
{
	int u=s;
	dis[u]=0;
	priority_queue<node>q;
	q.push(node(0,dis[u]));
	while(!q.empty())
	{
		u=q.top().u;
		ll disu=q.top().dd;
		q.pop();
		if(vis[u])
			continue;
		vis[u]=1;

		for(int i=head[u];i!=-1;i=nxt[i])
		{
			int v=to[i];
			if(dis[v]>disu+w[i])
			{
				dis[v]=disu+w[i];
				q.push(node(v,dis[v]));
			}
		}
	}
}

int main()
{
	int n,m;
	scanf("%d %d",&n,&m);
	init(n);int u,v;ll ww;
	for(int i=1;i<=m;i++)
	{
		scanf("%d %d %I64d",&u,&v,&ww);
		add(u,v,1ll*2*ww);
		add(v,u,1ll*2*ww);
	}
	ll t;
	for(int i=1;i<=n;i++)//super
	{
		scanf("%I64d",&t);
		add(0,i,t);
	}
	dij(0);
	printf("%I64d",dis[1]);
	for(int i=2;i<=n;i++)
		printf(" %I64d",dis[i]);
	printf("\n");
}


#include<iostream>
#include<stdio.h>
#include<string.h>
#include<queue>
using namespace std;
#define ll long long
const int maxn=200005;
const ll inf=(1ll<<60)-1;
int head[maxn];
int nxt[600005];
int to[600005];
ll w[600005];
ll dis[maxn];
int tot=0;
bool vis[maxn];
struct node{
	int u;
	ll dd;
	node(){}
	node(int a,int b):u(a),dd(b){}
	bool operator <(const node& c)const{
		return dd>c.dd;
	}
};

void add(int u,int v,ll ww)
{
	tot++;
	nxt[tot]=head[u];
	head[u]=tot;
	to[tot]=v;
	w[tot]=ww;
}
void init(int n)
{
	//memset(head,-1,sizeof(head));
	for(int i=0;i<=n;i++)
		dis[i]=inf,vis[i]=0,head[i]=-1;
	tot=0;
}
void dij(int s)
{
	int u=s;
	dis[u]=0;
	priority_queue<node>q;
	q.push(node(0,dis[u]));
	while(!q.empty())
	{
		u=q.top().u;
	//	ll disu=q.top().dd;
		q.pop();
		if(vis[u])
			continue;
		vis[u]=1;

		for(int i=head[u];i!=-1;i=nxt[i])
		{
			int v=to[i];
			if(dis[v]>dis[u]+w[i])
			{
				dis[v]=dis[u]+w[i];
				q.push(node(v,dis[v]));
			}
		}
	}
}

int main()
{
	int n,m;
	scanf("%d %d",&n,&m);
	init(n);int u,v;ll ww;
	for(int i=1;i<=m;i++)
	{
		scanf("%d %d %I64d",&u,&v,&ww);
		add(u,v,1ll*2*ww);
		add(v,u,1ll*2*ww);
	}
	ll t;
	for(int i=1;i<=n;i++)//super
	{
		scanf("%I64d",&t);
		add(0,i,t);
	}
	dij(0);
	printf("%I64d",dis[1]);
	for(int i=2;i<=n;i++)
		printf(" %I64d",dis[i]);
	printf("\n");
}


#include<iostream>
#include<stdio.h>
#include<string.h>
#include<queue>
using namespace std;
#define ll long long
const int maxn=200005;
const ll inf=0x3f3f3f3f3f3f3f3f;
int head[maxn];
int nxt[600005];
int to[600005];
ll w[600005];
ll dis[maxn];
int tot=0;
bool vis[maxn];
struct node{
	int u;
	ll dd;
	node(){}
	node(int a,int b):u(a),dd(b){}
	bool operator <(const node& c)const{
		return dd>c.dd;
	}
};

void add(int u,int v,ll ww)
{
	tot++;
	nxt[tot]=head[u];
	head[u]=tot;
	to[tot]=v;
	w[tot]=ww;
}
void init(int n)
{
	//memset(head,-1,sizeof(head));
	for(int i=0;i<=n;i++)
		dis[i]=inf,vis[i]=0,head[i]=-1;
	tot=0;
}
void dij(int s)
{
	int u=s;
	dis[u]=0;
	priority_queue<node>q;
	q.push(node(0,dis[u]));
	while(!q.empty())
	{
		u=q.top().u;
	//	ll disu=q.top().dd;
		q.pop();
		if(vis[u])
			continue;
		vis[u]=1;

		for(int i=head[u];i!=-1;i=nxt[i])
		{
			int v=to[i];
			if(dis[v]>dis[u]+w[i])
			{
				dis[v]=dis[u]+w[i];
				q.push(node(v,dis[v]));
			}
		}
	}
}

int main()
{
	int n,m;
	scanf("%d %d",&n,&m);
	init(n);int u,v;ll ww;
	for(int i=1;i<=m;i++)
	{
		scanf("%d %d %I64d",&u,&v,&ww);
		add(u,v,1ll*2*ww);
		add(v,u,1ll*2*ww);
	}
	ll t;
	for(int i=1;i<=n;i++)//super
	{
		scanf("%I64d",&t);
		add(0,i,t);
	}
	dij(0);
	printf("%I64d",dis[1]);
	for(int i=2;i<=n;i++)
		printf(" %I64d",dis[i]);
	printf("\n");
}


#include<iostream>
#include<stdio.h>
#include<string.h>
#include<queue>
using namespace std;
#define ll long long
const int maxn=200005;
const ll inf=(1ll<<60)-1;
int head[maxn];
int nxt[600005];
int to[600005];
ll w[600005];
ll dis[maxn];
int tot=0;
bool vis[maxn];
struct node{
	int u;
	ll dd;
	node(){}
	node(int a,int b):u(a),dd(b){}
	bool operator <(const node& c)const{
		return dd>c.dd;
	}
};

void add(int u,int v,ll ww)
{
	tot++;
	nxt[tot]=head[u];
	head[u]=tot;
	to[tot]=v;
	w[tot]=ww;
}
void init(int n)
{
	//memset(head,-1,sizeof(head));
	for(int i=0;i<=n;i++)
		dis[i]=inf,vis[i]=0,head[i]=-1;
	tot=0;
}
void dij(int s)
{
	int u=s;
	dis[u]=0;
	priority_queue<node>q;
	q.push(node(0,dis[u]));
	while(!q.empty())
	{
		u=q.top().u;
		ll disu=q.top().dd;
		q.pop();
		if(vis[u])
			continue;
		vis[u]=1;

		for(int i=head[u];i!=-1;i=nxt[i])
		{
			int v=to[i];
			if(dis[v]>disu+w[i])
			{
				dis[v]=disu+w[i];
				q.push(node(v,dis[v]));
			}
		}
	}
}

int main()
{
	int n,m;
	scanf("%d %d",&n,&m);
	init(n);int u,v;ll ww;
	for(int i=1;i<=m;i++)
	{
		scanf("%d %d %I64d",&u,&v,&ww);
		add(u,v,1ll*2*ww);
		add(v,u,1ll*2*ww);
	}
	ll t;
	for(int i=1;i<=n;i++)//super
	{
		scanf("%I64d",&t);
		add(0,i,t);
	}
	dij(0);
	printf("%I64d",dis[1]);
	for(int i=2;i<=n;i++)
		printf(" %I64d",dis[i]);
	printf("\n");
}


// #include<queue>
// #include<vector>
// #include<stdio.h>
// #include<string.h>
// #include<algorithm>
// using namespace std;
// #define ll long long
// #define maxn 200005
// #define inf ((1ll<<60-1))
// int n,m,vis[maxn];
// ll ans[maxn],dis[maxn];
// priority_queue<pair<ll,int> > t;
// vector<pair<int,ll> >q[maxn];
// void spfa(int st)
// {
	// for(int i=1;i<=n;i++)
	// 	dis[i]=inf;
	// t.push(make_pair(0,st));
    // dis[st] = 0;
// 	while(!t.empty())
// 	{
// 		int now = t.top().second;
// 		t.pop();
//         vis[now]=0;
// 		for(int i=0;i<q[now].size();i++)
// 		{
// 			int s=q[now][i].first;
// 			ll val=q[now][i].second;
// 			if(dis[s]>dis[now]+val)
// 			{
// 				dis[s]=dis[now]+val;
// 				if(!vis[s])
// 					vis[s]=1;
//                     t.push(make_pair(-dis[s],s));
// 			}
// 		}
// 	}
// }
// int main(void)
// {
// 	scanf("%d%d",&n,&m);
// 	for(int i=1;i<=m;i++)
// 	{
//         int x,y;
//         ll val;
// 		scanf("%d%d%lld",&x,&y,&val);
// 		q[x].push_back(make_pair(y,2ll*val));
// 		q[y].push_back(make_pair(x,2ll*val));
// 	}
// 	for(int i=1;i<=n;i++)
// 	{
//         ll val;
// 		scanf("%lld",&val);
// 		q[n+1].push_back(make_pair(i,val));
// 	}
// 	spfa(n+1);
// 	for(int i=1;i<=n;i++)
// 		printf("%lld ",dis[i]);
// 	printf("\n");
// 	return 0;
// }
#include<bits/stdc++.h>

using namespace std;

const int maxn = 2e5+5;
const int inf = 0x3f3f3f3f;
vector<pair<int,long long> >E[maxn];
priority_queue<pair<long long,int> > t;

int n,m;
long long d[maxn];

int main(){
    while(cin>>n>>m){
        for(int i = 0;i<m;i++){
            int x,y;
            long long z;
            cin>>x>>y>>z;
            E[x].push_back(make_pair(y,(long long)2*z));
            E[y].push_back(make_pair(x,(long long)2*z));
        }
        for(int i = 1; i <= n; i++){
            long long val;
            cin>>val;
            E[n+1].push_back(make_pair(i,val));
        }
        priority_queue<pair<int,int> >Q;
        for(int i=1;i<=n;i++)
            d[i]=inf;

        Q.push(make_pair(0,n+1));
        d[n+1] = 0;
        while(!Q.empty()){
            int now = Q.top().second;
            Q.pop();
            for(int i = 0;i<E[now].size();i++){
                int v = E[now][i].first;
                if(d[v]>d[now] + E[now][i].second){
                    d[v] = d[now] + E[now][i].second;
                    Q.push(make_pair(-d[v],v));
                }
            }
        }
        for(int i = 1; i <n ; i++)
            cout<<d[i]<<" ";
        cout<<d[n]<<endl;
    }

}


// #include<queue>
// #include<vector>
// #include<stdio.h>
// #include<string.h>
// #include<algorithm>
// using namespace std;
// #define ll long long
// #define maxn 200005
// #define inf ((1ll<<60-1))
// int n,m,vis[maxn];
// ll ans[maxn],dis[maxn];
// priority_queue<pair<ll,int> > t;
// vector<pair<int,ll> >q[maxn];
// void spfa(int st)
// {
	// for(int i=1;i<=n;i++)
	// 	dis[i]=inf;
	// t.push(make_pair(0,st));
    // dis[st] = 0;
// 	while(!t.empty())
// 	{
// 		int now = t.top().second;
// 		t.pop();
//         vis[now]=0;
// 		for(int i=0;i<q[now].size();i++)
// 		{
// 			int s=q[now][i].first;
// 			ll val=q[now][i].second;
// 			if(dis[s]>dis[now]+val)
// 			{
// 				dis[s]=dis[now]+val;
// 				if(!vis[s])
// 					vis[s]=1;
//                     t.push(make_pair(-dis[s],s));
// 			}
// 		}
// 	}
// }
// int main(void)
// {
// 	scanf("%d%d",&n,&m);
// 	for(int i=1;i<=m;i++)
// 	{
//      int x,y;
//      ll val;
// 		scanf("%d%d%lld",&x,&y,&val);
// 		q[x].push_back(make_pair(y,2ll*val));
// 		q[y].push_back(make_pair(x,2ll*val));
// 	}
// 	for(int i=1;i<=n;i++)
// 	{
//         ll val;
// 		scanf("%lld",&val);
// 		q[n+1].push_back(make_pair(i,val));
// 	}
// 	spfa(n+1);
// 	for(int i=1;i<=n;i++)
// 		printf("%lld ",dis[i]);
// 	printf("\n");
// 	return 0;
// }
#include<bits/stdc++.h>

using namespace std;
const int maxn = 2e5+5;
const long long inf =((1ll<<60-1));

vector<pair<int,long long> >E[maxn];
int vis[maxn];
int n,m;
long long d[maxn];

int main(){
    ios::sync_with_stdio(false);
    cin.tie(NUHLL);
    cout.tie(NULL);
    while(cin>>n>>m){
        for(int i = 0;i<m;i++){
            int x,y;
            long long z;
            cin>>x>>y>>z;
            E[x].push_back(make_pair(y,(long long)2*z));
            E[y].push_back(make_pair(x,(long long)2*z));
        }
        for(int i = 1; i <= n; i++){
            long long val;
            cin>>val;
            E[n+1].push_back(make_pair(i,val));
        }
        priority_queue<pair<long long,int> >Q;
        for(int i=1;i<=n;i++)
            d[i]=inf;
        Q.push(make_pair(0,n+1));
        d[n+1] = 0;
        while(!Q.empty()){
            int now = Q.top().second;
            vis[now] = 0;
            Q.pop();
            for(int i = 0;i<E[now].size();i++){
                int v = E[now][i].first;
                if(d[v]>d[now] + E[now][i].second){
                    d[v] = d[now] + E[now][i].second;
                    if(!vis[v])
                        vis[v] = 1;
                    Q.push(make_pair(-d[v],v));
                }
            }
        }
        for(int i = 1; i < n ; i++)
            cout<<d[i]<<" ";
        cout<<d[n]<<endl;
    }

}


// #include<queue>
// #include<vector>
// #include<stdio.h>
// #include<string.h>
// #include<algorithm>
// using namespace std;
// #define ll long long
// #define maxn 200005
// #define inf ((1ll<<60-1))
// int n,m,vis[maxn];
// ll ans[maxn],dis[maxn];
// priority_queue<pair<ll,int> > t;
// vector<pair<int,ll> >q[maxn];
// void spfa(int st)
// {
	// for(int i=1;i<=n;i++)
	// 	dis[i]=inf;
	// t.push(make_pair(0,st));
    // dis[st] = 0;
// 	while(!t.empty())
// 	{
// 		int now = t.top().second;
// 		t.pop();
//         vis[now]=0;
// 		for(int i=0;i<q[now].size();i++)
// 		{
// 			int s=q[now][i].first;
// 			ll val=q[now][i].second;
// 			if(dis[s]>dis[now]+val)
// 			{
// 				dis[s]=dis[now]+val;
// 				if(!vis[s])
// 					vis[s]=1;
//                     t.push(make_pair(-dis[s],s));
// 			}
// 		}
// 	}
// }
// int main(void)
// {
// 	scanf("%d%d",&n,&m);
// 	for(int i=1;i<=m;i++)
// 	{
//      int x,y;
//      ll val;
// 		scanf("%d%d%lld",&x,&y,&val);
// 		q[x].push_back(make_pair(y,2ll*val));
// 		q[y].push_back(make_pair(x,2ll*val));
// 	}
// 	for(int i=1;i<=n;i++)
// 	{
//         ll val;
// 		scanf("%lld",&val);
// 		q[n+1].push_back(make_pair(i,val));
// 	}
// 	spfa(n+1);
// 	for(int i=1;i<=n;i++)
// 		printf("%lld ",dis[i]);
// 	printf("\n");
// 	return 0;
// }
#include<bits/stdc++.h>

using namespace std;
const int maxn = 2e5+5;
const long long inf =((1ll<<60-1));

vector<pair<int,long long> >E[maxn];
int vis[maxn];
int n,m;
long long d[maxn];

int main(){

    while(scanf("%d%d",&n,&m)!=EOF){
        for(int i = 0;i<m;i++){
            int x,y;
            long long z;
            scanf("%d%d%lld",&x,&y,&z);
            E[x].push_back(make_pair(y,(long long)2*z));
            E[y].push_back(make_pair(x,(long long)2*z));
        }
        for(int i = 1; i <= n; i++){
            long long val;
            scanf("%lld",&val);
            E[n+1].push_back(make_pair(i,val));
        }
        priority_queue<pair<long long,int> >Q;
        for(int i=1;i<=n;i++)
            d[i]=inf;
        Q.push(make_pair(0,n+1));
        d[n+1] = 0;
        while(!Q.empty()){
            int now = Q.top().second;
            Q.pop();
            for(int i = 0;i<E[now].size();i++){
                int v = E[now][i].first;
                if(d[v]>d[now] + E[now][i].second){
                    d[v] = d[now] + E[now][i].second;
                    Q.push(make_pair(-d[v],v));
                }
            }
        }
        for(int i = 1; i < n ; i++)
            printf("%lld ",d[i]);
        printf("%lld ",d[n]);
    }
}


#include <bits/stdc++.h>
using namespace std;

#define LL long long
#define CLR(a,b) memset(a,(b),sizeof(a))

const LL MAXN = 2e5+11;
const LL INF = ~0ull>>1;
struct qnode
{
    LL v, c;
    qnode(LL _v=0, LL _c=0):v(_v),c(_c){}
    bool operator <(const qnode &r)const {
        return c > r.c;
    }
};
struct edge
{
    LL v, cost;
    edge(LL _v=0, LL _cost=0):v(_v),cost(_cost){}
};
vector<edge> E[MAXN];
bool vis[MAXN];
LL dis[MAXN];

void Dij(LL s,LL n)
{
    CLR(vis,false);
    for(LL i = 1; i <= n; i++) dis[i] = INF;
    priority_queue<qnode> que;
    while(!que.empty()) que.pop();
    dis[s] = 0;
    que.push(qnode(s,0));
    qnode tmp;
    while(!que.empty()) {
        tmp = que.top();
        que.pop();
        LL u = tmp.v;
        if(vis[u]) continue;
        vis[u] = true;
        for(LL i = 0; i < E[u].size(); i++) {
            LL v = E[u][i].v;
            LL cost = E[u][i].cost;
            if(!vis[v] && dis[v] > dis[u]+cost) {
                dis[v] = dis[u]+cost;
                que.push(qnode(v,dis[v]));
            }
        }
    }
}
void addedge(LL u, LL v, LL w)
{
    E[u].push_back(edge(v,w));
}
int main()
{
    ios::sync_with_stdio(false),cin.tie(0);
    LL n, m;
    LL x, y, z;
    cin >> n >> m;
    for(LL i = 0; i < m; i++) {
        cin >> x >> y >> z;
        addedge(x,y,z*2);
        addedge(y,x,z*2);
    }
    for(LL i = 1; i <= n; i++) {
        cin >> x;
        addedge(i,n+1,x);
        addedge(n+1,i,x);
    }
    Dij(n+1,n+1);
    for(LL i = 1; i <= n; i++) cout << dis[i] << ' ';
    cout << endl;
    return 0;
}


// #include<queue>
// #include<vector>
// #include<stdio.h>
// #include<string.h>
// #include<algorithm>
// using namespace std;
// #define ll long long
// #define maxn 200005
// #define inf ((1ll<<60-1))
// int n,m,vis[maxn];
// ll ans[maxn],dis[maxn];
// priority_queue<pair<ll,int> > t;
// vector<pair<int,ll> >q[maxn];
// void spfa(int st)
// {
	// for(int i=1;i<=n;i++)
	// 	dis[i]=inf;
	// t.push(make_pair(0,st));
    // dis[st] = 0;
// 	while(!t.empty())
// 	{
// 		int now = t.top().second;
// 		t.pop();
//         vis[now]=0;
// 		for(int i=0;i<q[now].size();i++)
// 		{
// 			int s=q[now][i].first;
// 			ll val=q[now][i].second;
// 			if(dis[s]>dis[now]+val)
// 			{
// 				dis[s]=dis[now]+val;
// 				if(!vis[s])
// 					vis[s]=1;
//                     t.push(make_pair(-dis[s],s));
// 			}
// 		}
// 	}
// }
// int main(void)
// {
// 	scanf("%d%d",&n,&m);
// 	for(int i=1;i<=m;i++)
// 	{
//         int x,y;
//         ll val;
// 		scanf("%d%d%lld",&x,&y,&val);
// 		q[x].push_back(make_pair(y,2ll*val));
// 		q[y].push_back(make_pair(x,2ll*val));
// 	}
// 	for(int i=1;i<=n;i++)
// 	{
//         ll val;
// 		scanf("%lld",&val);
// 		q[n+1].push_back(make_pair(i,val));
// 	}
// 	spfa(n+1);
// 	for(int i=1;i<=n;i++)
// 		printf("%lld ",dis[i]);
// 	printf("\n");
// 	return 0;
// }
#include<bits/stdc++.h>

using namespace std;

const int maxn = 2e5+5;
const long long inf =((1ll<<60-1));
vector<pair<int,long long> >E[maxn];

int n,m;
long long d[maxn];

int main(){
    while(cin>>n>>m){
        for(int i = 0;i<m;i++){
            int x,y;
            long long z;
            cin>>x>>y>>z;
            E[x].push_back(make_pair(y,(long long)2*z));
            E[y].push_back(make_pair(x,(long long)2*z));
        }
        for(int i = 1; i <= n; i++){
            long long val;
            cin>>val;
            E[n+1].push_back(make_pair(i,val));
        }
        priority_queue<pair<long long,int> >Q;
        for(int i=1;i<=n;i++)
            d[i]=inf;

        Q.push(make_pair(0,n+1));
        d[n+1] = 0;
        while(!Q.empty()){
            int now = Q.top().second;
            Q.pop();
            for(int i = 0;i<E[now].size();i++){
                int v = E[now][i].first;
                if(d[v]>d[now] + E[now][i].second){
                    d[v] = d[now] + E[now][i].second;
                    Q.push(make_pair(-d[v],v));
                }
            }
        }
        for(int i = 1; i < n ; i++)
            cout<<d[i]<<" ";
        cout<<d[n]<<endl;
    }

}


#include<bits/stdc++.h>

using namespace std;
const int maxn = 2e5+5;
const long long inf =((1ll<<60-1));

vector<pair<int,long long> >E[maxn];
int vis[maxn],n,m;
long long d[maxn];

void dij(){
    priority_queue<pair<long long,int> >Q;
    for(int i=1;i<=n;i++)
        d[i]=inf;
    Q.push(make_pair(0,0));
    d[0] = 0;
    while(!Q.empty()){
        int now = Q.top().second;
        vis[now] = 0;
        Q.pop();
        for(int i = 0;i<E[now].size();i++){
            int s = E[now][i].first;
            long long val = E[now][i].second;
            if(d[s]>d[now] +val){
                d[s] = d[now] +val;
                if(!vis[s]){
                    vis[s] = 1;
                Q.push(make_pair(-d[s],s));
                }
            }
        }
    }
}

int main(){
    while(scanf("%d%d",&n,&m)!=EOF){
        for(int i = 0;i<m;i++){
            int x,y;
            long long z;
            scanf("%d%d%lld",&x,&y,&z);
            E[x].push_back(make_pair(y,(long long)2*z));
            E[y].push_back(make_pair(x,(long long)2*z));
        }
        for(int i = 1; i <= n; i++){
            long long val;
            scanf("%lld",&val);
            E[0].push_back(make_pair(i,val));
        }
        dij();
        for(int i = 1; i <= n ; i++)
            printf("%lld ",d[i]);
        printf("\n");
    }
}


// #include<queue>
// #include<vector>
// #include<stdio.h>
// #include<string.h>
// #include<algorithm>
// using namespace std;
// #define ll long long
// #define maxn 200005
// #define inf ((1ll<<60-1))
// int n,m,vis[maxn];
// ll ans[maxn],dis[maxn];
// priority_queue<pair<ll,int> > t;
// vector<pair<int,ll> >q[maxn];
// void spfa(int st)
// {
	// for(int i=1;i<=n;i++)
	// 	dis[i]=inf;
	// t.push(make_pair(0,st));
    // dis[st] = 0;
// 	while(!t.empty())
// 	{
// 		int now = t.top().second;
// 		t.pop();
//         vis[now]=0;
// 		for(int i=0;i<q[now].size();i++)
// 		{
// 			int s=q[now][i].first;
// 			ll val=q[now][i].second;
// 			if(dis[s]>dis[now]+val)
// 			{
// 				dis[s]=dis[now]+val;
// 				if(!vis[s])
// 					vis[s]=1;
//                     t.push(make_pair(-dis[s],s));
// 			}
// 		}
// 	}
// }
// int main(void)
// {
// 	scanf("%d%d",&n,&m);
// 	for(int i=1;i<=m;i++)
// 	{
//         int x,y;
//         ll val;
// 		scanf("%d%d%lld",&x,&y,&val);
// 		q[x].push_back(make_pair(y,2ll*val));
// 		q[y].push_back(make_pair(x,2ll*val));
// 	}
// 	for(int i=1;i<=n;i++)
// 	{
//         ll val;
// 		scanf("%lld",&val);
// 		q[n+1].push_back(make_pair(i,val));
// 	}
// 	spfa(n+1);
// 	for(int i=1;i<=n;i++)
// 		printf("%lld ",dis[i]);
// 	printf("\n");
// 	return 0;
// }
#include<bits/stdc++.h>

using namespace std;

const int maxn = 2e5+5;
const int inf =((1ll<<60-1));
vector<pair<int,long long> >E[maxn];

int n,m;
long long d[maxn];

int main(){
    while(cin>>n>>m){
        for(int i = 0;i<m;i++){
            int x,y;
            long long z;
            cin>>x>>y>>z;
            E[x].push_back(make_pair(y, long long 2*z));
            E[y].push_back(make_pair(x,long long 2*z));
        }
        for(int i = 1; i <= n; i++){
            long long val;
            cin>>val;
            E[n+1].push_back(make_pair(i,val));
        }
        priority_queue<pair<long long,int> >Q;
        for(int i=1;i<=n;i++)
            d[i]=inf;

        Q.push(make_pair(0,n+1));
        d[n+1] = 0;
        while(!Q.empty()){
            int now = Q.top().second;
            Q.pop();
            for(int i = 0;i<E[now].size();i++){
                int v = E[now][i].first;
                if(d[v]>d[now] + E[now][i].second){
                    d[v] = d[now] + E[now][i].second;
                    Q.push(make_pair(-d[v],v));
                }
            }
        }
        for(int i = 1; i < n ; i++)
            cout<<d[i]<<" ";
        cout<<d[n]<<endl;
    }

}


// #include<queue>
// #include<vector>
// #include<stdio.h>
// #include<string.h>
// #include<algorithm>
// using namespace std;
// #define ll long long
// #define maxn 200005
// #define inf ((1ll<<60-1))
// int n,m,vis[maxn];
// ll ans[maxn],dis[maxn];
// priority_queue<pair<ll,int> > t;
// vector<pair<int,ll> >q[maxn];
// void spfa(int st)
// {
	// for(int i=1;i<=n;i++)
	// 	dis[i]=inf;
	// t.push(make_pair(0,st));
    // dis[st] = 0;
// 	while(!t.empty())
// 	{
// 		int now = t.top().second;
// 		t.pop();
//         vis[now]=0;
// 		for(int i=0;i<q[now].size();i++)
// 		{
// 			int s=q[now][i].first;
// 			ll val=q[now][i].second;
// 			if(dis[s]>dis[now]+val)
// 			{
// 				dis[s]=dis[now]+val;
// 				if(!vis[s])
// 					vis[s]=1;
//                     t.push(make_pair(-dis[s],s));
// 			}
// 		}
// 	}
// }
// int main(void)
// {
// 	scanf("%d%d",&n,&m);
// 	for(int i=1;i<=m;i++)
// 	{
//         int x,y;
//         ll val;
// 		scanf("%d%d%lld",&x,&y,&val);
// 		q[x].push_back(make_pair(y,2ll*val));
// 		q[y].push_back(make_pair(x,2ll*val));
// 	}
// 	for(int i=1;i<=n;i++)
// 	{
//         ll val;
// 		scanf("%lld",&val);
// 		q[n+1].push_back(make_pair(i,val));
// 	}
// 	spfa(n+1);
// 	for(int i=1;i<=n;i++)
// 		printf("%lld ",dis[i]);
// 	printf("\n");
// 	return 0;
// }
#include<bits/stdc++.h>

using namespace std;

const int maxn = 2e5+5;
const int inf = 0x3f3f3f3f;
vector<pair<int,long long> >E[maxn];
priority_queue<pair<long long,int> > t;

int n,m;
long long d[maxn];
void init()
{

    for(int i = 1;i<=n;i++){
        d[i] = inf;
    }

}

int main(){
    while(cin>>n>>m){
        init();
        for(int i = 0;i<m;i++){
            int x,y;
            long long z;
            scanf("%d%d%d",&x,&y,&z);
            E[x].push_back(make_pair(y,(long long)2*z));
            E[y].push_back(make_pair(x,(long long)2*z));
        }
        for(int i = 1; i <= n; i++){
            long long val;
            cin>>val;
            E[n+1].push_back(make_pair(i,val));
        }
        priority_queue<pair<int,int> >Q;
        for(int i=1;i<=n;i++)
            d[i]=inf;

        Q.push(make_pair(0,n+1));
        d[n+1] = 0;
        while(!Q.empty()){
            int now = Q.top().second;
            Q.pop();
            for(int i = 0;i<E[now].size();i++){
                int v = E[now][i].first;
                if(d[v]>d[now] + E[now][i].second){
                    d[v] = d[now] + E[now][i].second;
                    Q.push(make_pair(-d[v],v));
                }
            }
        }
        for(int i = 1; i <n ; i++)
            printf("%lld ",d[i]);
        printf("%lld\n",d[n]);
    }

}


#include<bits/stdc++.h>

using namespace std;
const int maxn = 2e5+5;
const long long inf =((1ll<<60-1));

vector<pair<int,long long> >E[maxn];
int vis[maxn];
int n,m;
long long d[maxn];

int main(){

    while(scanf("%d%d",&n,&m)!=EOF){
        for(int i = 0;i<m;i++){
            int x,y;
            long long z;
            scanf("%d%d%lld",&x,&y,&z);
            E[x].push_back(make_pair(y,(long long)2*z));
            E[y].push_back(make_pair(x,(long long)2*z));
        }
        for(int i = 1; i <= n; i++){
            long long val;
            scanf("%lld",&val);
            E[n+1].push_back(make_pair(i,val));
        }

        priority_queue<pair<long long,int> >Q;

        for(long long i=1;i<=n;i++)
            d[i]=inf;
        Q.push(make_pair(0,n+1));
        d[n+1] = 0;
        memset(vis,false,sizeof(vis));
        while(!Q.empty()){
            int now = Q.top().second;
            Q.pop();
            if(vis[now]) continue;
            vis[now] = 0;
            for(int i = 0;i<E[now].size();i++){
                int s = E[now][i].first;
                long long val = E[now][i].second;
                if(d[s]>d[now] +val){
                    d[s] = d[now] +val;
                    if(!vis[s]) vis[s] = 1;
                    Q.push(make_pair(-d[s],s));
                }
            }
        }
        for(int i = 1; i <= n ; i++)
            printf("%lld ",d[i]);
        printf("\n");
    }
}


#include<bits/stdc++.h>

using namespace std;
const int maxn = 2e5+5;
const long long inf =((1ll<<60-1));

vector<pair<int,long long> >E[maxn];
int vis[maxn];
int n,m;
long long d[maxn];

int main(){

    while(scanf("%d%d",&n,&m)!=EOF){
        for(int i = 0;i<m;i++){
            int x,y;
            long long z;
            scanf("%d%d%lld",&x,&y,&z);
            E[x].push_back(make_pair(y,(long long)2*z));
            E[y].push_back(make_pair(x,(long long)2*z));
        }
        for(int i = 1; i <= n; i++){
            long long val;
            scanf("%lld",&val);
            E[n+1].push_back(make_pair(i,val));
        }

        priority_queue<pair<long long,int> >Q;

        for(int i=1;i<=n;i++)
            d[i]=inf;
        Q.push(make_pair(0,n+1));
        d[n+1] = 0;
        while(!Q.empty()){
            int now = Q.top().second;
            Q.pop();
            vis[now] = 0;
            for(int i = 0;i<E[now].size();i++){
                int s = E[now][i].first;
                long long val = E[now][i].second;
                if(d[s]>d[now] +val){
                    d[s] = d[now] +val;
                    if(!vis[s]) vis[s] = 1;
                    Q.push(make_pair(-d[s],s));
                }
            }
        }
        for(int i = 1; i <= n ; i++)
            printf("%lld ",d[i]);
        printf("\n");
    }
}


// #include<queue>
// #include<vector>
// #include<stdio.h>
// #include<string.h>
// #include<algorithm>
// using namespace std;
// #define ll long long
// #define maxn 200005
// #define inf ((1ll<<60-1))
// int n,m,vis[maxn];
// ll ans[maxn],dis[maxn];
// priority_queue<pair<ll,int> > t;
// vector<pair<int,ll> >q[maxn];
// void spfa(int st)
// {
	// for(int i=1;i<=n;i++)
	// 	dis[i]=inf;
	// t.push(make_pair(0,st));
    // dis[st] = 0;
// 	while(!t.empty())
// 	{
// 		int now = t.top().second;
// 		t.pop();
//         vis[now]=0;
// 		for(int i=0;i<q[now].size();i++)
// 		{
// 			int s=q[now][i].first;
// 			ll val=q[now][i].second;
// 			if(dis[s]>dis[now]+val)
// 			{
// 				dis[s]=dis[now]+val;
// 				if(!vis[s])
// 					vis[s]=1;
//                     t.push(make_pair(-dis[s],s));
// 			}
// 		}
// 	}
// }
// int main(void)
// {
// 	scanf("%d%d",&n,&m);
// 	for(int i=1;i<=m;i++)
// 	{
//      int x,y;
//      ll val;
// 		scanf("%d%d%lld",&x,&y,&val);
// 		q[x].push_back(make_pair(y,2ll*val));
// 		q[y].push_back(make_pair(x,2ll*val));
// 	}
// 	for(int i=1;i<=n;i++)
// 	{
//         ll val;
// 		scanf("%lld",&val);
// 		q[n+1].push_back(make_pair(i,val));
// 	}
// 	spfa(n+1);
// 	for(int i=1;i<=n;i++)
// 		printf("%lld ",dis[i]);
// 	printf("\n");
// 	return 0;
// }
#include<bits/stdc++.h>

using namespace std;
const int maxn = 2e5+5;
const long long inf =((1ll<<60-1));

vector<pair<int,long long> >E[maxn];
int vis[maxn];
int n,m;
long long d[maxn];

int main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    while(cin>>n>>m){
        for(int i = 0;i<m;i++){
            int x,y;
            long long z;
            cin>>x>>y>>z;
            E[x].push_back(make_pair(y,(long long)2*z));
            E[y].push_back(make_pair(x,(long long)2*z));
        }
        for(int i = 1; i <= n; i++){
            long long val;
            cin>>val;
            E[n+1].push_back(make_pair(i,val));
        }
        priority_queue<pair<long long,int> >Q;
        for(int i=1;i<=n;i++)
            d[i]=inf;
        Q.push(make_pair(0,n+1));
        d[n+1] = 0;
        while(!Q.empty()){
            int now = Q.top().second;
            Q.pop();
            for(int i = 0;i<E[now].size();i++){
                int v = E[now][i].first;
                if(d[v]>d[now] + E[now][i].second){
                    d[v] = d[now] + E[now][i].second;
                    Q.push(make_pair(-d[v],v));
                }
            }
        }
        for(int i = 1; i < n ; i++)
            cout<<d[i]<<" ";
        cout<<d[n]<<endl;
    }

}


#include<queue>
#include<vector>
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
#define ll long long
#define maxn 200005
#define inf ((1ll<<60-1))
int n,m,vis[maxn];
ll ans[maxn],dis[maxn];
priority_queue<pair<ll,int> > t;
vector<pair<int,ll> >q[maxn];
void spfa(int st)
{
	for(int i=1;i<=n;i++)
		dis[i]=inf;
	t.push(make_pair(0,st));
    dis[st] = 0;
	while(!t.empty())
	{
		int now = t.top().second;
		t.pop();
        vis[now]=0;
		for(int i=0;i<q[now].size();i++)
		{
			int s=q[now][i].first;
			ll val=q[now][i].second;
			if(dis[s]>dis[now]+val)
			{
				dis[s]=dis[now]+val;
				if(!vis[s])
					vis[s]=1;
                    t.push(make_pair(-dis[s],s));
			}
		}
	}
}
int main(void)
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++)
	{
     int x,y;
     ll val;
		scanf("%d%d%lld",&x,&y,&val);
		q[x].push_back(make_pair(y,2ll*val));
		q[y].push_back(make_pair(x,2ll*val));
	}
	for(int i=1;i<=n;i++)
	{
        ll val;
		scanf("%lld",&val);
		q[n+1].push_back(make_pair(i,val));
	}
	spfa(n+1);
	for(int i=1;i<=n;i++)
		printf("%lld ",dis[i]);
	printf("\n");
	return 0;
}


#include <queue>
#include <cstring>
#include <cstdio>
#define maxn 2000005
#define maxm 2000005
#define MAX 100000000000100
#define ll long long

using namespace std;

queue<int>q;
int n,m,tot,f,r,x,y;
bool vis[maxn];
ll z,now,dis[maxn],w[maxm];
int v[maxn],Next[maxm],Head[maxn];

inline void addedge(int x,int y,ll z)
{
	v[++tot]=y,w[tot]=z;
	Next[tot]=Head[x],Head[x]=tot;
}

void spfa()
{
	q.push(n+1);
	dis[n+1]=0;
	vis[n+1]=true;
	while(!q.empty())
	{
		int x=q.front();
		for(int i=Head[x];i;i=Next[i])
		{
			if(dis[x]+w[i]<dis[v[i]])
			{
				dis[v[i]]=dis[x]+w[i];
				if(!vis[v[i]]) q.push(v[i]);
			}
		}
		vis[x]=false;
		q.pop();
	}
}

int main ()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++)
	{
		scanf("%d%d%lld",&x,&y,&z);
		addedge(x,y,z*2);addedge(y,x,z*2);
	}
	for(int i=1;i<=n;i++)
	{
		scanf("%lld",&now);
		addedge(n+1,i,now);
		dis[i]=MAX;
	}
	spfa();
	for(int i=1;i<=n;i++)
	  printf("%lld ",dis[i]);
	return 0;
}


#include<bits/stdc++.h>
using namespace std;

const int maxn=2e5+7;
int n,m;

struct edge{
	int to,nxt;
	long long w;
}E[maxn<<2];
int head[maxn<<1],cnt=1;

void addedge(int u,int v,long long w)
{
	E[cnt].to=v;
	E[cnt].nxt=head[u];
	E[cnt].w=w;
	head[u]=cnt++;
}

struct node{
	int in;
	long long w;
	friend bool operator <(node a,node b){
		return a.w<b.w;
	}
	friend bool operator >(node a,node b){
		return b<a;
	}
	node(int _in,long long _w){in=_in,w=_w;}
};

long long dist[maxn];
int vis[maxn];
void dij()
{
	memset(dist,127,sizeof(dist));
	priority_queue<node,vector<node>,greater<node> > q;
	q.push(node(n+1,0));
	dist[n+1]=0;
	while(!q.empty()){
		node now=q.top();q.pop();
		int in=now.in;
		long long w=now.w;
		if(vis[in])continue;
		vis[in]=1;
		for(int i=head[in];i;i=E[i].nxt){
			int to=E[i].to;
			if(dist[to]>dist[in]+E[i].w){
				dist[to]=dist[in]+E[i].w;
				q.push(node(to,dist[to]));
			}
		}
	}
}

int main()
{
	scanf("%d %d",&n,&m);
	for(int i=1;i<=m;++i){
		int u,v;
		long long w;
		scanf("%d %d %lld",&u,&v,&w);
		addedge(u,v,2*w);
		addedge(v,u,2*w);
	}
	for(int i=1;i<=n;++i){
		long long w;
		scanf("%lld",&w);
		addedge(n+1,i,w);
	}
	dij();
	for(int i=1;i<=n;++i)printf("%lld ",dist[i]);
}


#include<bits/stdc++.h>
#define maxn 600010
using namespace std;
int dis[maxn];
bool vis[maxn];
priority_queue<pair<long long ,int>,vector<pair<long long,int> >,greater<pair<long long ,int> > > q;
struct edge{
    long long val,to;
};
vector<edge> e[maxn];
void dijkstra(int n,int m,int s){
    for(int i=1;i<=n;i++)
        dis[i]=1e9;
    dis[s]=0;
    q.push(make_pair(0,s));
    while(!q.empty()){
        long long x=q.top().second;
        q.pop();
        if(vis[x])
            continue;
        vis[x]=1;
        for(int i=0;i<e[x].size();i++){
            long long y=e[x][i].to;
            if(dis[x]+e[x][i].val<dis[y]){
                dis[y]=dis[x]+e[x][i].val;
                q.push(make_pair(dis[y],y));
            }
        }
    }
}
int main(){
    int n,m;
    cin>>n>>m;
    for(int i=1;i<=m;i++){
        long long x,y,z;
        cin>>x>>y>>z;
        edge tmp;
        tmp.val=z*2;
        tmp.to=y;
        e[x].push_back(tmp);
        edge tmp2;
        tmp2.val=z*2;
        tmp2.to=x;
        e[y].push_back(tmp2);
    }
    int nn=n+1;
    for(int i=1;i<=n;i++){
        long long x;
        cin>>x;
        edge tmp;
        tmp.to=i;
        tmp.val=x;
        e[nn].push_back(tmp);
    }
    dijkstra(nn,m+n,nn);
    for(int i=1;i<=n;i++)
        cout<<dis[i]<<" ";
    return 0;
}


#include <fstream>
#include <iomanip>
#include <iostream>
#include <algorithm>　　　 //STL 通用算法
#include <bitset>　　　　　//STL 位集容器
#include <cctype>         //字符处理
#include <cerrno> 　　　　 //定义错误码
#include <cfloat>　　　　  //浮点数处理
#include <ciso646>        //对应各种运算符的宏
#include <climits> 　　　　//定义各种数据类型最值的常量
#include <clocale> 　　　　//定义本地化函数
#include <cmath> 　　　　　//定义数学函数
#include <complex>　　　　 //复数类
#include <csignal>        //信号机制支持
#include <csetjmp>        //异常处理支持
#include <cstdarg>        //不定参数列表支持
#include <cstddef>        //常用常量
#include <cstdio> 　　　　 //定义输入／输出函数
#include <cstdlib> 　　　　//定义杂项函数及内存分配函数
#include <cstring> 　　　　//字符串处理
#include <ctime> 　　　　　//定义关于时间的函数
#include <cwchar> 　　　　 //宽字符处理及输入／输出
#include <cwctype> 　　　　//宽字符分类
#include <deque>　　　　　 //STL 双端队列容器
#include <exception>　　　 //异常处理类
#include <fstream> 　　　  //文件输入／输出
#include <functional>　　  //STL 定义运算函数（代替运算符）
#include <limits> 　　　　 //定义各种数据类型最值常量
#include <list>　　　　　　//STL 线性列表容器
#include <locale>         //本地化特定信息
#include <map>　　　　　　 //STL 映射容器
#include <memory>         //STL通过分配器进行的内存分配
#include<new>             //动态内存分配
#include <numeric>        //STL常用的数字操作
#include <iomanip> 　　　  //参数化输入／输出
#include <ios>　　　　　　 //基本输入／输出支持
#include <iosfwd>　　　　　//输入／输出系统使用的前置声明
#include <iostream> 　　　 //数据流输入／输出
#include <istream>　　　　 //基本输入流
#include <iterator>       //STL迭代器
#include <ostream>　　　　 //基本输出流
#include <queue>　　　　　 //STL 队列容器
#include <set>　　　　　　 //STL 集合容器
#include <sstream>　　　　 //基于字符串的流
#include <stack>　　　　　 //STL 堆栈容器
#include <stdexcept>　　　 //标准异常类
#include <streambuf>　　　 //底层输入／输出支持
#include <string>　　　　　//字符串类
#include <typeinfo>       //运行期间类型信息
#include <utility>　　　　 //STL 通用模板类
#include <valarray>       //对包含值的数组的操作
#include <vector>
#define N 200005
#define ll long long
#define maxn 0x3f3f3f3f
using namespace std;
ll head[N],dist[N],x[N],y[N],z[N],vist[N],cnt=0,n,m,ans[N],zz[N];

struct node{
	ll to,next,w;
}a[2*N];
ll read(){
	ll x=0,s=1;
	char c=getchar();
	while(c<'0'||c>'9'){
		if(c=='-')
		s=-1;
		c=getchar();
	}
	while(c>='0'&&c<='9'){
		x=x*10+c-'0';
		c=getchar();
	}
	return x*s;
}
void dj(ll x){
	for(int i=1;i<=n;i++)
	dist[i]=0x7f7f7f7f7f7f7f7f7f7f7f7f;
//cout<<dist[n]<<"qwe";
	memset(vist,0,sizeof(vist));
	dist[x]=0;

	queue<int>q;

	q.push(x);
	while(q.size())
{
	ll x=q.front();
	q.pop();
	if(vist[x])
	continue;
	vist[x]=1;
	for(ll i=head[x];i;i=a[i].next)
	{
		int y=a[i].to;
		if(dist[y]>a[i].w+dist[x])

		dist[y]=a[i].w+dist[x];

		//if(!vist[y])
		q.push(y);
	}
}
}
void add(ll x,ll y,ll z){
	a[++cnt].w=z;
	a[cnt].next=head[x];
	a[cnt].to=y;
	head[x]=cnt;
}
void work(){
	for(ll i=1;i<=m;i++){
	x[i]=read(),y[i]=read(),z[i]=read();
	add(x[i],y[i],2*z[i]);
	add(y[i],x[i],2*z[i]);
		}
	for(ll i=1;i<=n;i++){
		zz[i]=read();
		add(0,i,0);
		add(i,0,0);
	}

	for(ll i=1;i<=n;i++)
	ans[i]=maxn;
	//for(ll i=1;i<=n;i++){
		dj(0);
for(ll j=1;j<=n;j++){
ans[j]=min(ans[j],dist[j]+zz[j]);
	printf("%lld ",ans[j]);
}

	//}

}
int main(){
	n=read(),m=read();
	work();
	return 0;

}


#include <stdio.h>
#include <iostream>
#include <string.h>
#include <algorithm>
#include <queue>
#define maxn 200001
using namespace std;
typedef long long int lli;
lli n,m,id=0,hd[maxn],nxt[maxn],d[maxn],v[maxn];
struct edge
{
	lli x,y,z;
	edge(lli x=0,lli y=0,lli z=0):x(x),y(y),z(z){}
};
edge e[maxn];
queue <lli> Q;
inline lli read()
{
	lli f=1,x=0;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return f*x;
}
void init()
{
	memset(v,1,sizeof(v));
	memset(d,0x3f,sizeof(d));
}
void add(lli x,lli y,lli z)
{
	id++;
	e[id]=edge(x,y,z);
	nxt[id]=hd[x];
	hd[x]=id;
}
void spfa()
{
	d[0]=0;
	Q.push(0);
	v[0]=0;
	while(!Q.empty())
	{
		lli x=Q.front();
		v[x]=1;
		Q.pop();
		for(lli i=hd[x];i;i=nxt[i])
		{
			lli y=e[i].y;
			if(d[y]>d[x]+e[i].z)
			{
				d[y]=d[x]+e[i].z;
				if(v[y])
				{
					Q.push(y);
					v[y]=0;
				}
			}
		}
	}
}
int main()
{
	init();
	n=read();
	m=read();
	for(lli i=1;i<=m;i++)
	{
		lli x,y,z;
		x=read();
		y=read();
		z=read();
		add(x,y,2*z);
		add(y,x,2*z);
	}
	for(lli i=1;i<=n;i++)
	{
		lli x=0,y=i,z;
		z=read();
		add(x,y,z);
	}
	spfa();
	for(lli i=1;i<=n;i++)
	{
		printf("%lld ",d[i]);
	}
	printf("\n");
	return 0;
}