Mishka is trying really hard to avoid being kicked out of the university. In particular, he was doing absolutely nothing for the whole semester, miraculously passed some exams so that just one is left.There were $$$n$$$ classes of that subject during the semester and on $$$i$$$-th class professor mentioned some non-negative integer $$$a_i$$$ to the students. It turned out, the exam was to tell the whole sequence back to the professor. Sounds easy enough for those who attended every class, doesn't it?Obviously Mishka didn't attend any classes. However, professor left some clues on the values of $$$a$$$ to help out students like Mishka:   $$$a$$$ was sorted in non-decreasing order ($$$a_1 \le a_2 \le \dots \le a_n$$$);  $$$n$$$ was even;  the following sequence $$$b$$$, consisting of $$$\frac n 2$$$ elements, was formed and given out to students: $$$b_i = a_i + a_{n - i + 1}$$$. Professor also mentioned that any sequence $$$a$$$, which produces sequence $$$b$$$ with the presented technique, will be acceptable.Help Mishka to pass that last exam. Restore any sorted sequence $$$a$$$ of non-negative integers, which produces sequence $$$b$$$ with the presented technique. It is guaranteed that there exists at least one correct sequence $$$a$$$, which produces the given sequence $$$b$$$.

The first line contains a single integer $$$n$$$ ($$$2 \le n \le 2 \cdot 10^5$$$) — the length of sequence $$$a$$$. $$$n$$$ is always even. The second line contains $$$\frac n 2$$$ integers $$$b_1, b_2, \dots, b_{\frac n 2}$$$ ($$$0 \le b_i \le 10^{18}$$$) — sequence $$$b$$$, where $$$b_i = a_i + a_{n - i + 1}$$$. It is guaranteed that there exists at least one correct sequence $$$a$$$, which produces the given sequence $$$b$$$.

Print $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$0 \le a_i \le 10^{18}$$$) in a single line. $$$a_1 \le a_2 \le \dots \le a_n$$$ should be satisfied. $$$b_i = a_i + a_{n - i + 1}$$$ should be satisfied for all valid $$$i$$$.

const readline = require('readline');
const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
});
!function(e){"use strict";var r,L=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,B=Math.ceil,T=Math.floor,U="[BigNumber Error] ",I=U+"Number primitive has more than 15 significant digits: ",C=1e14,M=14,G=9007199254740991,F=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],k=1e7,q=1e9;function j(e){var r=0|e;return 0<e||e===r?r:r-1}function $(e){for(var r,n,t=1,i=e.length,o=e[0]+"";t<i;){for(r=e[t++]+"",n=M-r.length;n--;r="0"+r);o+=r}for(i=o.length;48===o.charCodeAt(--i););return o.slice(0,i+1||1)}function z(e,r){var n,t,i=e.c,o=r.c,s=e.s,f=r.s,u=e.e,l=r.e;if(!s||!f)return null;if(n=i&&!i[0],t=o&&!o[0],n||t)return n?t?0:-f:s;if(s!=f)return s;if(n=s<0,t=u==l,!i||!o)return t?0:!i^n?1:-1;if(!t)return l<u^n?1:-1;for(f=(u=i.length)<(l=o.length)?u:l,s=0;s<f;s++)if(i[s]!=o[s])return i[s]>o[s]^n?1:-1;return u==l?0:l<u^n?1:-1}function H(e,r,n,t){if(e<r||n<e||e!==(e<0?B(e):T(e)))throw Error(U+(t||"Argument")+("number"==typeof e?e<r||n<e?" out of range: ":" not an integer: ":" not a primitive number: ")+String(e))}function V(e){var r=e.c.length-1;return j(e.e/M)==r&&e.c[r]%2!=0}function W(e,r){return(1<e.length?e.charAt(0)+"."+e.slice(1):e)+(r<0?"e":"e+")+r}function X(e,r,n){var t,i;if(r<0){for(i=n+".";++r;i+=n);e=i+e}else if(++r>(t=e.length)){for(i=n,r-=t;--r;i+=n);e+=i}else r<t&&(e=e.slice(0,r)+"."+e.slice(r));return e}(r=function e(r){var v,a,h,n,l,s,f,u,c,p,t=_.prototype={constructor:_,toString:null,valueOf:null},w=new _(1),y=20,N=4,g=-7,i=21,m=-1e7,d=1e7,O=!1,o=1,b=0,E={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:" ",suffix:""},A="0123456789abcdefghijklmnopqrstuvwxyz";function _(e,r){var n,t,i,o,s,f,u,l,c=this;if(!(c instanceof _))return new _(e,r);if(null==r){if(e instanceof _)return c.s=e.s,c.e=e.e,void(c.c=(e=e.c)?e.slice():e);if((f="number"==typeof e)&&0*e==0){if(c.s=1/e<0?(e=-e,-1):1,e===~~e){for(o=0,s=e;10<=s;s/=10,o++);return c.e=o,void(c.c=[e])}l=String(e)}else{if(l=String(e),!L.test(l))return h(c,l,f);c.s=45==l.charCodeAt(0)?(l=l.slice(1),-1):1}-1<(o=l.indexOf("."))&&(l=l.replace(".","")),0<(s=l.search(/e/i))?(o<0&&(o=s),o+=+l.slice(s+1),l=l.substring(0,s)):o<0&&(o=l.length)}else{if(H(r,2,A.length,"Base"),l=String(e),10==r)return x(c=new _(e instanceof _?e:l),y+c.e+1,N);if(f="number"==typeof e){if(0*e!=0)return h(c,l,f,r);if(c.s=1/e<0?(l=l.slice(1),-1):1,_.DEBUG&&15<l.replace(/^0\.0*|\./,"").length)throw Error(I+e);f=!1}else c.s=45===l.charCodeAt(0)?(l=l.slice(1),-1):1;for(n=A.slice(0,r),o=s=0,u=l.length;s<u;s++)if(n.indexOf(t=l.charAt(s))<0){if("."==t){if(o<s){o=u;continue}}else if(!i&&(l==l.toUpperCase()&&(l=l.toLowerCase())||l==l.toLowerCase()&&(l=l.toUpperCase()))){i=!0,s=-1,o=0;continue}return h(c,String(e),f,r)}-1<(o=(l=a(l,r,10,c.s)).indexOf("."))?l=l.replace(".",""):o=l.length}for(s=0;48===l.charCodeAt(s);s++);for(u=l.length;48===l.charCodeAt(--u););if(l=l.slice(s,++u)){if(u-=s,f&&_.DEBUG&&15<u&&(G<e||e!==T(e)))throw Error(I+c.s*e);if(d<(o=o-s-1))c.c=c.e=null;else if(o<m)c.c=[c.e=0];else{if(c.e=o,c.c=[],s=(o+1)%M,o<0&&(s+=M),s<u){for(s&&c.c.push(+l.slice(0,s)),u-=M;s<u;)c.c.push(+l.slice(s,s+=M));l=l.slice(s),s=M-l.length}else s-=u;for(;s--;l+="0");c.c.push(+l)}}else c.c=[c.e=0]}function S(e,r,n,t){var i,o,s,f,u;if(null==n?n=N:H(n,0,8),!e.c)return e.toString();if(i=e.c[0],s=e.e,null==r)u=$(e.c),u=1==t||2==t&&s<=g?W(u,s):X(u,s,"0");else if(o=(e=x(new _(e),r,n)).e,f=(u=$(e.c)).length,1==t||2==t&&(r<=o||o<=g)){for(;f<r;u+="0",f++);u=W(u,o)}else if(r-=s,u=X(u,o,"0"),f<o+1){if(0<--r)for(u+=".";r--;u+="0");}else if(0<(r+=o-f))for(o+1==f&&(u+=".");r--;u+="0");return e.s<0&&i?"-"+u:u}function R(e,r){for(var n,t=1,i=new _(e[0]);t<e.length;t++){if(!(n=new _(e[t])).s){i=n;break}r.call(i,n)&&(i=n)}return i}function P(e,r,n){for(var t=1,i=r.length;!r[--i];r.pop());for(i=r[0];10<=i;i/=10,t++);return(n=t+n*M-1)>d?e.c=e.e=null:e.c=n<m?[e.e=0]:(e.e=n,r),e}function x(e,r,n,t){var i,o,s,f,u,l,c,a=e.c,h=F;if(a){e:{for(i=1,f=a[0];10<=f;f/=10,i++);if((o=r-i)<0)o+=M,s=r,c=(u=a[l=0])/h[i-s-1]%10|0;else if((l=B((o+1)/M))>=a.length){if(!t)break e;for(;a.length<=l;a.push(0));u=c=0,s=(o%=M)-M+(i=1)}else{for(u=f=a[l],i=1;10<=f;f/=10,i++);c=(s=(o%=M)-M+i)<0?0:u/h[i-s-1]%10|0}if(t=t||r<0||null!=a[l+1]||(s<0?u:u%h[i-s-1]),t=n<4?(c||t)&&(0==n||n==(e.s<0?3:2)):5<c||5==c&&(4==n||t||6==n&&(0<o?0<s?u/h[i-s]:0:a[l-1])%10&1||n==(e.s<0?8:7)),r<1||!a[0])return a.length=0,t?(r-=e.e+1,a[0]=h[(M-r%M)%M],e.e=-r||0):a[0]=e.e=0,e;if(0==o?(a.length=l,f=1,l--):(a.length=l+1,f=h[M-o],a[l]=0<s?T(u/h[i-s]%h[s])*f:0),t)for(;;){if(0==l){for(o=1,s=a[0];10<=s;s/=10,o++);for(s=a[0]+=f,f=1;10<=s;s/=10,f++);o!=f&&(e.e++,a[0]==C&&(a[0]=1));break} if(a[l]+=f,a[l]!=C)break;a[l--]=0,f=1}for(o=a.length;0===a[--o];a.pop());}e.e>d?e.c=e.e=null:e.e<m&&(e.c=[e.e=0])}return e}function D(e){var r,n=e.e;return null===n?e.toString():(r=$(e.c),r=n<=g||i<=n?W(r,n):X(r,n,"0"),e.s<0?"-"+r:r)}return _.clone=e,_.ROUND_UP=0,_.ROUND_DOWN=1,_.ROUND_CEIL=2,_.ROUND_FLOOR=3,_.ROUND_HALF_UP=4,_.ROUND_HALF_DOWN=5,_.ROUND_HALF_EVEN=6,_.ROUND_HALF_CEIL=7,_.ROUND_HALF_FLOOR=8,_.EUCLID=9,_.config=_.set=function(e){var r,n;if(null!=e){if("object"!=typeof e)throw Error(U+"Object expected: "+e);if(e.hasOwnProperty(r="DECIMAL_PLACES")&&(H(n=e[r],0,q,r),y=n),e.hasOwnProperty(r="ROUNDING_MODE")&&(H(n=e[r],0,8,r),N=n),e.hasOwnProperty(r="EXPONENTIAL_AT")&&((n=e[r])&&n.pop?(H(n[0],-q,0,r),H(n[1],0,q,r),g=n[0],i=n[1]):(H(n,-q,q,r),g=-(i=n<0?-n:n))),e.hasOwnProperty(r="RANGE"))if((n=e[r])&&n.pop)H(n[0],-q,-1,r),H(n[1],1,q,r),m=n[0],d=n[1];else{if(H(n,-q,q,r),!n)throw Error(U+r+" cannot be zero: "+n);m=-(d=n<0?-n:n)}if(e.hasOwnProperty(r="CRYPTO")){if((n=e[r])!==!!n)throw Error(U+r+" not true or false: "+n);if(n){if("undefined"==typeof crypto||!crypto||!crypto.getRandomValues&&!crypto.randomBytes)throw O=!n,Error(U+"crypto unavailable");O=n}else O=n}if(e.hasOwnProperty(r="MODULO_MODE")&&(H(n=e[r],0,9,r),o=n),e.hasOwnProperty(r="POW_PRECISION")&&(H(n=e[r],0,q,r),b=n),e.hasOwnProperty(r="FORMAT")){if("object"!=typeof(n=e[r]))throw Error(U+r+" not an object: "+n);E=n}if(e.hasOwnProperty(r="ALPHABET")){if("string"!=typeof(n=e[r])||/^.$|[+-.\s]|(.).*\1/.test(n))throw Error(U+r+" invalid: "+n);A=n}}return{DECIMAL_PLACES:y,ROUNDING_MODE:N,EXPONENTIAL_AT:[g,i],RANGE:[m,d],CRYPTO:O,MODULO_MODE:o,POW_PRECISION:b,FORMAT:E,ALPHABET:A}},_.isBigNumber=function(e){return e instanceof _||e&&!0===e._isBigNumber||!1},_.maximum=_.max=function(){return R(arguments,t.lt)},_.minimum=_.min=function(){return R(arguments,t.gt)},_.random=(n=9007199254740992,l=Math.random()*n&2097151?function(){return T(Math.random()*n)}:function(){return 8388608*(1073741824*Math.random()|0)+(8388608*Math.random()|0)},function(e){var r,n,t,i,o,s=0,f=[],u=new _(w);if(null==e?e=y:H(e,0,q),i=B(e/M),O)if(crypto.getRandomValues){for(r=crypto.getRandomValues(new Uint32Array(i*=2));s<i;)9e15<=(o=131072*r[s]+(r[s+1]>>>11))?(n=crypto.getRandomValues(new Uint32Array(2)),r[s]=n[0],r[s+1]=n[1]):(f.push(o%1e14),s+=2);s=i/2}else{if(!crypto.randomBytes)throw O=!1,Error(U+"crypto unavailable");for(r=crypto.randomBytes(i*=7);s<i;)9e15<=(o=281474976710656*(31&r[s])+1099511627776*r[s+1]+4294967296*r[s+2]+16777216*r[s+3]+(r[s+4]<<16)+(r[s+5]<<8)+r[s+6])?crypto.randomBytes(7).copy(r,s):(f.push(o%1e14),s+=7);s=i/7}if(!O)for(;s<i;) (o=l())<9e15&&(f[s++]=o%1e14);for(i=f[--s],e%=M,i&&e&&(o=F[M-e],f[s]=T(i/o)*o);0===f[s];f.pop(),s--);if(s<0)f=[t=0];else{for(t=-1;0===f[0];f.splice(0,1),t-=M);for(s=1,o=f[0];10<=o;o/=10,s++);s<M&&(t-=M-s)}return u.e=t,u.c=f,u}),_.sum=function(){for(var e=1,r=arguments,n=new _(r[0]);e<r.length;)n=n.plus(r[e++]);return n},a=function(){var m="0123456789";function d(e,r,n,t){for(var i,o,s=[0],f=0,u=e.length;f<u;){for(o=s.length;o--;s[o]*=r);for(s[0]+=t.indexOf(e.charAt(f++)),i=0;i<s.length;i++)s[i]>n-1&&(null==s[i+1]&&(s[i+1]=0),s[i+1]+=s[i]/n|0,s[i]%=n)}return s.reverse()}return function(e,r,n,t,i){var o,s,f,u,l,c,a,h,p=e.indexOf("."),g=y,w=N;for(0<=p&&(u=b,b=0,e=e.replace(".",""),c=(h=new _(r)).pow(e.length-p),b=u,h.c=d(X($(c.c),c.e,"0"),10,n,m),h.e=h.c.length),f=u=(a=d(e,r,n,i?(o=A,m):(o=m,A))).length;0==a[--u];a.pop());if(!a[0])return o.charAt(0);if(p<0?--f:(c.c=a,c.e=f,c.s=t,a=(c=v(c,h,g,w,n)).c,l=c.r,f=c.e),p=a[s=f+g+1],u=n/2,l=l||s<0||null!=a[s+1],l=w<4?(null!=p||l)&&(0==w||w==(c.s<0?3:2)):u<p||p==u&&(4==w||l||6==w&&1&a[s-1]||w==(c.s<0?8:7)),s<1||!a[0])e=l?X(o.charAt(1),-g,o.charAt(0)):o.charAt(0);else{if(a.length=s,l)for(--n;++a[--s]>n;)a[s]=0,s||(++f,a=[1].concat(a));for(u=a.length;!a[--u];);for(p=0,e="";p<=u;e+=o.charAt(a[p++]));e=X(e,f,o.charAt(0))}return e}}(),v=function(){function S(e,r,n){var t,i,o,s,f=0,u=e.length,l=r%k,c=r/k|0;for(e=e.slice();u--;)f=((i=l*(o=e[u]%k)+(t=c*o+(s=e[u]/k|0)*l)%k*k+f)/n|0)+(t/k|0)+c*s,e[u]=i%n;return f&&(e=[f].concat(e)),e}function R(e,r,n,t){var i,o;if(n!=t)o=t<n?1:-1;else for(i=o=0;i<n;i++)if(e[i]!=r[i]){o=e[i]>r[i]?1:-1;break}return o}function P(e,r,n,t){for(var i=0;n--;)e[n]-=i,i=e[n]<r[n]?1:0,e[n]=i*t+e[n]-r[n];for(;!e[0]&&1<e.length;e.splice(0,1));}return function(e,r,n,t,i){var o,s,f,u,l,c,a,h,p,g,w,m,d,v,y,N,O,b=e.s==r.s?1:-1,E=e.c,A=r.c;if(!(E&&E[0]&&A&&A[0]))return new _(e.s&&r.s&&(E?!A||E[0]!=A[0]:A)?E&&0==E[0]||!A?0*b:b/0:NaN);for(p=(h=new _(b)).c=[],b=n+(s=e.e-r.e)+1,i||(i=C,s=j(e.e/M)-j(r.e/M),b=b/M|0),f=0;A[f]==(E[f]||0);f++);if(A[f]>(E[f]||0)&&s--,b<0)p.push(1),u=!0;else{for(v=E.length,N=A.length,b+=2,1<(l=T(i/(A[f=0]+1)))&&(A=S(A,l,i),E=S(E,l,i),N=A.length,v=E.length),d=N,w=(g=E.slice(0,N)).length;w<N;g[w++]=0);O=A.slice(),O=[0].concat(O),y=A[0],A[1]>=i/2&&y++;do{if(l=0,(o=R(A,g,N,w))<0){if(m=g[0],N!=w&&(m=m*i+(g[1]||0)),1<(l=T(m/y)))for(i<=l&&(l=i-1),a=(c=S(A,l,i)).length,w=g.length;1==R(c,g,a,w);)l--,P(c,N<a?O:A,a,i),a=c.length,o=1;else 0==l&&(o=l=1),a=(c=A.slice()).length;if(a<w&&(c=[0].concat(c)),P(g,c,w,i),w=g.length,-1==o)for(;R(A,g,N,w)<1;)l++,P(g,N<w?O:A,w,i),w=g.length}else 0===o&&(l++,g=[0]);p[f++]=l,g[0]?g[w++]=E[d]||0:(g=[E[d]],w=1)}while((d++<v||null!=g[0])&&b--);u=null!=g[0],p[0]||p.splice(0,1)}if(i==C){for(f=1,b=p[0];10<=b;b/=10,f++);x(h,n+(h.e=f+s*M-1)+1,t,u)}else h.e=s,h.r=+u;return h}}(),s=/^(-?)0([xbo])(?=\w[\w.]*$)/i,f=/^([^.]+)\.$/,u=/^\.([^.]+)$/,c=/^-?(Infinity|NaN)$/,p=/^\s*\+(?=[\w.])|^\s+|\s+$/g,h=function(e,r,n,t){var i,o=n?r:r.replace(p,"");if(c.test(o))e.s=isNaN(o)?null:o<0?-1:1,e.c=e.e=null;else{if(!n&&(o=o.replace(s,function(e,r,n){return i="x"==(n=n.toLowerCase())?16:"b"==n?2:8,t&&t!=i?e:r}),t&&(i=t,o=o.replace(f,"$1").replace(u,"0.$1")),r!=o))return new _(o,i);if(_.DEBUG)throw Error(U+"Not a"+(t?" base "+t:"")+" number: "+r);e.c=e.e=e.s=null}},t.absoluteValue=t.abs=function(){var e=new _(this);return e.s<0&&(e.s=1),e},t.comparedTo=function(e,r){return z(this,new _(e,r))},t.decimalPlaces=t.dp=function(e,r){var n,t,i;if(null!=e)return H(e,0,q),null==r?r=N:H(r,0,8),x(new _(this),e+this.e+1,r);if(!(n=this.c))return null;if(t=((i=n.length-1)-j(this.e/M))*M,i=n[i])for(;i%10==0;i/=10,t--);return t<0&&(t=0),t},t.dividedBy=t.div=function(e,r){return v(this,new _(e,r),y,N)},t.dividedToIntegerBy=t.idiv=function(e,r){return v(this,new _(e,r),0,1)},t.exponentiatedBy=t.pow=function(e,r){var n,t,i,o,s,f,u,l,c=this;if((e=new _(e)).c&&!e.isInteger())throw Error(U+"Exponent not an integer: "+D(e));if(null!=r&&(r=new _(r)),s=14<e.e,!c.c||!c.c[0]||1==c.c[0]&&!c.e&&1==c.c.length||!e.c||!e.c[0])return l=new _(Math.pow(+D(c),s?2-V(e):+D(e))),r?l.mod(r):l;if(f=e.s<0,r){if(r.c?!r.c[0]:!r.s)return new _(NaN);(t=!f&&c.isInteger()&&r.isInteger())&&(c=c.mod(r))}else{if(9<e.e&&(0<c.e||c.e<-1||(0==c.e?1<c.c[0]||s&&24e7<=c.c[1]:c.c[0]<8e13||s&&c.c[0]<=9999975e7)))return o=c.s<0&&V(e)?-0:0,-1<c.e&&(o=1/o),new _(f?1/o:o);b&&(o=B(b/M+2))}for(u=s?(n=new _(.5),f&&(e.s=1),V(e)):(i=Math.abs(+D(e)))%2,l=new _(w);;){if(u){if(!(l=l.times(c)).c)break;o?l.c.length>o&&(l.c.length=o):t&&(l=l.mod(r))}if(i){if(0===(i=T(i/2)))break;u=i%2}else if(x(e=e.times(n),e.e+1,1),14<e.e)u=V(e);else{if(0==(i=+D(e)))break;u=i%2}c=c.times(c),o?c.c&&c.c.length>o&&(c.c.length=o):t&&(c=c.mod(r))}return t?l:(f&&(l=w.div(l)),r?l.mod(r):o?x(l,b,N,void 0):l)},t.integerValue=function(e){var r=new _(this);return null==e?e=N:H(e,0,8),x(r,r.e+1,e)},t.isEqualTo=t.eq=function(e,r){return 0===z(this,new _(e,r))},t.isFinite=function(){return!!this.c},t.isGreaterThan=t.gt=function(e,r){return 0<z(this,new _(e,r))},t.isGreaterThanOrEqualTo=t.gte=function(e,r){return 1===(r=z(this,new _(e,r)))||0===r},t.isInteger=function(){return!!this.c&&j(this.e/M)>this.c.length-2},t.isLessThan=t.lt=function(e,r){return z(this,new _(e,r))<0},t.isLessThanOrEqualTo=t.lte=function(e,r){return-1===(r=z(this,new _(e,r)))||0===r},t.isNaN=function(){return!this.s},t.isNegative=function(){return this.s<0},t.isPositive=function(){return 0<this.s},t.isZero=function(){return!!this.c&&0==this.c[0]},t.minus=function(e,r){var n,t,i,o,s=this,f=s.s;if(r=(e=new _(e,r)).s,!f||!r)return new _(NaN);if(f!=r)return e.s=-r,s.plus(e);var u=s.e/M,l=e.e/M,c=s.c,a=e.c;if(!u||!l){if(!c||!a)return c?(e.s=-r,e):new _(a?s:NaN);if(!c[0]||!a[0])return a[0]?(e.s=-r,e):new _(c[0]?s:3==N?-0:0)}if(u=j(u),l=j(l),c=c.slice(),f=u-l){for((i=(o=f<0)?(f=-f,c):(l=u,a)).reverse(),r=f;r--;i.push(0));i.reverse()}else for(t=(o=(f=c.length)<(r=a.length))?f:r,f=r=0;r<t;r++)if(c[r]!=a[r]){o=c[r]<a[r];break}if(o&&(i=c,c=a,a=i,e.s=-e.s),0<(r=(t=a.length)-(n=c.length)))for(;r--;c[n++]=0);for(r=C-1;f<t;){if(c[--t]<a[t]){for(n=t;n&&!c[--n];c[n]=r);--c[n],c[t]+=C}c[t]-=a[t]}for(;0==c[0];c.splice(0,1),--l);return c[0]?P(e,c,l):(e.s=3==N?-1:1,e.c=[e.e=0],e)},t.modulo=t.mod=function(e,r){var n,t,i=this;return e=new _(e,r),!i.c||!e.s||e.c&&!e.c[0]?new _(NaN):!e.c||i.c&&!i.c[0]?new _(i):(9==o?(t=e.s,e.s=1,n=v(i,e,0,3),e.s=t,n.s*=t):n=v(i,e,0,o),(e=i.minus(n.times(e))).c[0]||1!=o||(e.s=i.s),e)},t.multipliedBy=t.times=function(e,r){var n,t,i,o,s,f,u,l,c,a,h,p,g,w,m,d=this,v=d.c,y=(e=new _(e,r)).c;if(!(v&&y&&v[0]&&y[0]))return!d.s||!e.s||v&&!v[0]&&!y||y&&!y[0]&&!v?e.c=e.e=e.s=null:(e.s*=d.s,v&&y?(e.c=[0],e.e=0):e.c=e.e=null),e;for(t=j(d.e/M)+j(e.e/M),e.s*=d.s,(u=v.length)<(a=y.length)&&(g=v,v=y,y=g,i=u,u=a,a=i),i=u+a,g=[];i--;g.push(0));for(w=C,m=k,i=a;0<=--i;){for(n=0,h=y[i]%m,p=y[i]/m|0,o=i+(s=u);i<o;)n=((l=h*(l=v[--s]%m)+(f=p*l+(c=v[s]/m|0)*h)%m*m+g[o]+n)/w|0)+(f/m|0)+p*c,g[o--]=l%w;g[o]=n}return n?++t:g.splice(0,1),P(e,g,t)},t.negated=function(){var e=new _(this);return e.s=-e.s||null,e},t.plus=function(e,r){var n,t=this,i=t.s;if(r=(e=new _(e,r)).s,!i||!r)return new _(NaN);if(i!=r)return e.s=-r,t.minus(e);var o=t.e/M,s=e.e/M,f=t.c,u=e.c;if(!o||!s){if(!f||!u)return new _(i/0);if(!f[0]||!u[0])return u[0]?e:new _(f[0]?t:0*i)}if(o=j(o),s=j(s),f=f.slice(),i=o-s){for((n=0<i?(s=o,u):(i=-i,f)).reverse();i--;n.push(0));n.reverse()}for((i=f.length)-(r=u.length)<0&&(n=u,u=f,f=n,r=i),i=0;r;)i=(f[--r]=f[r]+u[r]+i)/C|0,f[r]=C===f[r]?0:f[r]%C;return i&&(f=[i].concat(f),++s),P(e,f,s)},t.precision=t.sd=function(e,r){var n,t,i;if(null!=e&&e!==!!e)return H(e,1,q),null==r?r=N:H(r,0,8),x(new _(this),e,r);if(!(n=this.c))return null;if(t=(i=n.length-1)*M+1,i=n[i]){for(;i%10==0;i/=10,t--);for(i=n[0];10<=i;i/=10,t++);}return e&&this.e+1>t&&(t=this.e+1),t},t.shiftedBy=function(e){return H(e,-G,G),this.times("1e"+e)},t.squareRoot=t.sqrt=function(){var e,r,n,t,i,o=this,s=o.c,f=o.s,u=o.e,l=y+4,c=new _("0.5");if(1!==f||!s||!s[0])return new _(!f||f<0&&(!s||s[0])?NaN:s?o:1/0);if((n=0==(f=Math.sqrt(+D(o)))||f==1/0?(((r=$(s)).length+u)%2==0&&(r+="0"),f=Math.sqrt(+r),u=j((u+1)/2)-(u<0||u%2),new _(r=f==1/0?"1e"+u:(r=f.toExponential()).slice(0,r.indexOf("e")+1)+u)):new _(f+"")).c[0])for((f=(u=n.e)+l)<3&&(f=0);;)if(i=n,n=c.times(i.plus(v(o,i,l,1))),$(i.c).slice(0,f)===(r=$(n.c)).slice(0,f)){if(n.e<u&&--f,"9999"!=(r=r.slice(f-3,f+1))&&(t||"4999"!=r)){+r&&(+r.slice(1)||"5"!=r.charAt(0))||(x(n,n.e+y+2,1),e=!n.times(n).eq(o));break}if(!t&&(x(i,i.e+y+2,0),i.times(i).eq(o))){n=i;break}l+=4,f+=4,t=1}return x(n,n.e+y+1,N,e)},t.toExponential=function(e,r){return null!=e&&(H(e,0,q),e++),S(this,e,r,1)},t.toFixed=function(e,r){return null!=e&&(H(e,0,q),e=e+this.e+1),S(this,e,r)},t.toFormat=function(e,r,n){var t;if(null==n)null!=e&&r&&"object"==typeof r?(n=r,r=null):e&&"object"==typeof e?(n=e,e=r=null):n=E;else if("object"!=typeof n)throw Error(U+"Argument not an object: "+n);if(t=this.toFixed(e,r),this.c){var i,o=t.split("."),s=+n.groupSize,f=+n.secondaryGroupSize,u=n.groupSeparator||"",l=o[0],c=o[1],a=this.s<0,h=a?l.slice(1):l,p=h.length;if(f&&(i=s,s=f,p-=f=i),0<s&&0<p){for(i=p%s||s,l=h.substr(0,i);i<p;i+=s)l+=u+h.substr(i,s);0<f&&(l+=u+h.slice(i)),a&&(l="-"+l)}t=c?l+(n.decimalSeparator||"")+((f=+n.fractionGroupSize)?c.replace(new RegExp("\\d{"+f+"}\\B","g"),"$&"+(n.fractionGroupSeparator||"")):c):l}return(n.prefix||"")+t+(n.suffix||"")},t.toFraction=function(e){var r,n,t,i,o,s,f,u,l,c,a,h,p=this,g=p.c;if(null!=e&&(!(f=new _(e)).isInteger()&&(f.c||1!==f.s)||f.lt(w)))throw Error(U+"Argument "+(f.isInteger()?"out of range: ":"not an integer: ")+D(f));if(!g)return new _(p);for(r=new _(w),l=n=new _(w),t=u=new _(w),h=$(g),o=r.e=h.length-p.e-1,r.c[0]=F[(s=o%M)<0?M+s:s],e=!e||0<f.comparedTo(r)?0<o?r:l:f,s=d,d=1/0,f=new _(h),u.c[0]=0;c=v(f,r,0,1),1!=(i=n.plus(c.times(t))).comparedTo(e);)n=t,t=i,l=u.plus(c.times(i=l)),u=i,r=f.minus(c.times(i=r)),f=i;return i=v(e.minus(n),t,0,1),u=u.plus(i.times(l)),n=n.plus(i.times(t)),u.s=l.s=p.s,a=v(l,t,o*=2,N).minus(p).abs().comparedTo(v(u,n,o,N).minus(p).abs())<1?[l,t]:[u,n],d=s,a},t.toNumber=function(){return+D(this)},t.toPrecision=function(e,r){return null!=e&&H(e,1,q),S(this,e,r,2)},t.toString=function(e){var r,n=this.s,t=this.e;return null===t?n?(r="Infinity",n<0&&(r="-"+r)):r="NaN":(r=$(this.c),r=null==e?t<=g||i<=t?W(r,t):X(r,t,"0"):(H(e,2,A.length,"Base"),a(X(r,t,"0"),10,e,n,!0)),n<0&&this.c[0]&&(r="-"+r)),r},t.valueOf=t.toJSON=function(){return D(this)},t._isBigNumber=!0,"function"==typeof Symbol&&"symbol"==typeof Symbol.iterator&&(t[Symbol.toStringTag]="BigNumber",t[Symbol.for("nodejs.util.inspect.custom")]=t.valueOf),null!=r&&_.set(r),_}()).default=r.BigNumber=r,"function"==typeof define&&define.amd?define(function(){return r}):"undefined"!=typeof module&&module.exports?module.exports=r:(e||(e="undefined"!=typeof self&&self?self:window),e.BigNumber=r)}(this);

const BN = module.exports.BigNumber;

let l = 0;
rl.on('line', (input) => {
    if (l == 0) { l++ }
    else {
        rl.close();
        let strArray = input.split(" ")
        let s = strArray.map(function (item) {
            return BN(item);
        });
        let res = []
        let n = s.length * 2
        res[0] = BN(0)
        res[n - 1] = s[0]
        for (let i = 1; i < s.length; i++) {
            if (s[i].minus(res[i - 1]).gt(res[n - (i - 1) - 1])) {

                res[i] = s[i].minus(res[n - (i - 1) - 1])
                if (res[i - 1].gt(res[i])) {
                    res[i] = res[i].minus(res[i - 1])
                }
                res[n - i - 1] = s[i].minus(res[i])

            } else {
                res[i] = res[i - 1]
                res[n - i - 1] = s[i].minus(res[i - 1])
            }
        }
        console.log(res.join(" "))
        return 0;
    }
});

function main() {

    const BN = module.exports.BigNumber;

    var n = stdin[0];
    n = parseInt(n);

    var b = stdin[1].split(' ').map( (s) => { return BN(s); });

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

    for(var i=1 ; i<n/2 ; i++) {
        if( b[i].lt(b[i-1]) ) {
            a[i] = a[i-1];
            a[n-i-1] = b[i].minus(a[i]);
        } else {
            a[n-i-1] = a[n-i];
            a[i] = b[i].minus(a[n-i-1]);
        }
    }

    for(var i=0 ; i<n ; i++) {
        process.stdout.write(a[i].toFixed() + " ");
    }

}

const readline = require('readline');
const rl = readline.createInterface(process.stdin, process.stdout, null);

var stdin = [];
rl.on('line', function (line) {stdin.push(line);});
rl.on('close', main);

/* bignumber.js v8.0.1 https://github.com/MikeMcl/bignumber.js/LICENCE */
!function(e){"use strict";var r,L=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,B=Math.ceil,T=Math.floor,U="[BigNumber Error] ",I=U+"Number primitive has more than 15 significant digits: ",C=1e14,M=14,G=9007199254740991,F=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],k=1e7,q=1e9;function j(e){var r=0|e;return 0<e||e===r?r:r-1}function $(e){for(var r,n,t=1,i=e.length,o=e[0]+"";t<i;){for(r=e[t++]+"",n=M-r.length;n--;r="0"+r);o+=r}for(i=o.length;48===o.charCodeAt(--i););return o.slice(0,i+1||1)}function z(e,r){var n,t,i=e.c,o=r.c,s=e.s,f=r.s,u=e.e,l=r.e;if(!s||!f)return null;if(n=i&&!i[0],t=o&&!o[0],n||t)return n?t?0:-f:s;if(s!=f)return s;if(n=s<0,t=u==l,!i||!o)return t?0:!i^n?1:-1;if(!t)return l<u^n?1:-1;for(f=(u=i.length)<(l=o.length)?u:l,s=0;s<f;s++)if(i[s]!=o[s])return i[s]>o[s]^n?1:-1;return u==l?0:l<u^n?1:-1}function H(e,r,n,t){if(e<r||n<e||e!==(e<0?B(e):T(e)))throw Error(U+(t||"Argument")+("number"==typeof e?e<r||n<e?" out of range: ":" not an integer: ":" not a primitive number: ")+String(e))}function V(e){var r=e.c.length-1;return j(e.e/M)==r&&e.c[r]%2!=0}function W(e,r){return(1<e.length?e.charAt(0)+"."+e.slice(1):e)+(r<0?"e":"e+")+r}function X(e,r,n){var t,i;if(r<0){for(i=n+".";++r;i+=n);e=i+e}else if(++r>(t=e.length)){for(i=n,r-=t;--r;i+=n);e+=i}else r<t&&(e=e.slice(0,r)+"."+e.slice(r));return e}(r=function e(r){var v,a,h,n,l,s,f,u,c,p,t=_.prototype={constructor:_,toString:null,valueOf:null},w=new _(1),y=20,N=4,g=-7,i=21,m=-1e7,d=1e7,O=!1,o=1,b=0,E={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:" ",suffix:""},A="0123456789abcdefghijklmnopqrstuvwxyz";function _(e,r){var n,t,i,o,s,f,u,l,c=this;if(!(c instanceof _))return new _(e,r);if(null==r){if(e instanceof _)return c.s=e.s,c.e=e.e,void(c.c=(e=e.c)?e.slice():e);if((f="number"==typeof e)&&0*e==0){if(c.s=1/e<0?(e=-e,-1):1,e===~~e){for(o=0,s=e;10<=s;s/=10,o++);return c.e=o,void(c.c=[e])}l=String(e)}else{if(l=String(e),!L.test(l))return h(c,l,f);c.s=45==l.charCodeAt(0)?(l=l.slice(1),-1):1}-1<(o=l.indexOf("."))&&(l=l.replace(".","")),0<(s=l.search(/e/i))?(o<0&&(o=s),o+=+l.slice(s+1),l=l.substring(0,s)):o<0&&(o=l.length)}else{if(H(r,2,A.length,"Base"),l=String(e),10==r)return x(c=new _(e instanceof _?e:l),y+c.e+1,N);if(f="number"==typeof e){if(0*e!=0)return h(c,l,f,r);if(c.s=1/e<0?(l=l.slice(1),-1):1,_.DEBUG&&15<l.replace(/^0\.0*|\./,"").length)throw Error(I+e);f=!1}else c.s=45===l.charCodeAt(0)?(l=l.slice(1),-1):1;for(n=A.slice(0,r),o=s=0,u=l.length;s<u;s++)if(n.indexOf(t=l.charAt(s))<0){if("."==t){if(o<s){o=u;continue}}else if(!i&&(l==l.toUpperCase()&&(l=l.toLowerCase())||l==l.toLowerCase()&&(l=l.toUpperCase()))){i=!0,s=-1,o=0;continue}return h(c,String(e),f,r)}-1<(o=(l=a(l,r,10,c.s)).indexOf("."))?l=l.replace(".",""):o=l.length}for(s=0;48===l.charCodeAt(s);s++);for(u=l.length;48===l.charCodeAt(--u););if(l=l.slice(s,++u)){if(u-=s,f&&_.DEBUG&&15<u&&(G<e||e!==T(e)))throw Error(I+c.s*e);if(d<(o=o-s-1))c.c=c.e=null;else if(o<m)c.c=[c.e=0];else{if(c.e=o,c.c=[],s=(o+1)%M,o<0&&(s+=M),s<u){for(s&&c.c.push(+l.slice(0,s)),u-=M;s<u;)c.c.push(+l.slice(s,s+=M));l=l.slice(s),s=M-l.length}else s-=u;for(;s--;l+="0");c.c.push(+l)}}else c.c=[c.e=0]}function S(e,r,n,t){var i,o,s,f,u;if(null==n?n=N:H(n,0,8),!e.c)return e.toString();if(i=e.c[0],s=e.e,null==r)u=$(e.c),u=1==t||2==t&&s<=g?W(u,s):X(u,s,"0");else if(o=(e=x(new _(e),r,n)).e,f=(u=$(e.c)).length,1==t||2==t&&(r<=o||o<=g)){for(;f<r;u+="0",f++);u=W(u,o)}else if(r-=s,u=X(u,o,"0"),f<o+1){if(0<--r)for(u+=".";r--;u+="0");}else if(0<(r+=o-f))for(o+1==f&&(u+=".");r--;u+="0");return e.s<0&&i?"-"+u:u}function R(e,r){for(var n,t=1,i=new _(e[0]);t<e.length;t++){if(!(n=new _(e[t])).s){i=n;break}r.call(i,n)&&(i=n)}return i}function P(e,r,n){for(var t=1,i=r.length;!r[--i];r.pop());for(i=r[0];10<=i;i/=10,t++);return(n=t+n*M-1)>d?e.c=e.e=null:e.c=n<m?[e.e=0]:(e.e=n,r),e}function x(e,r,n,t){var i,o,s,f,u,l,c,a=e.c,h=F;if(a){e:{for(i=1,f=a[0];10<=f;f/=10,i++);if((o=r-i)<0)o+=M,s=r,c=(u=a[l=0])/h[i-s-1]%10|0;else if((l=B((o+1)/M))>=a.length){if(!t)break e;for(;a.length<=l;a.push(0));u=c=0,s=(o%=M)-M+(i=1)}else{for(u=f=a[l],i=1;10<=f;f/=10,i++);c=(s=(o%=M)-M+i)<0?0:u/h[i-s-1]%10|0}if(t=t||r<0||null!=a[l+1]||(s<0?u:u%h[i-s-1]),t=n<4?(c||t)&&(0==n||n==(e.s<0?3:2)):5<c||5==c&&(4==n||t||6==n&&(0<o?0<s?u/h[i-s]:0:a[l-1])%10&1||n==(e.s<0?8:7)),r<1||!a[0])return a.length=0,t?(r-=e.e+1,a[0]=h[(M-r%M)%M],e.e=-r||0):a[0]=e.e=0,e;if(0==o?(a.length=l,f=1,l--):(a.length=l+1,f=h[M-o],a[l]=0<s?T(u/h[i-s]%h[s])*f:0),t)for(;;){if(0==l){for(o=1,s=a[0];10<=s;s/=10,o++);for(s=a[0]+=f,f=1;10<=s;s/=10,f++);o!=f&&(e.e++,a[0]==C&&(a[0]=1));break} if(a[l]+=f,a[l]!=C)break;a[l--]=0,f=1}for(o=a.length;0===a[--o];a.pop());}e.e>d?e.c=e.e=null:e.e<m&&(e.c=[e.e=0])}return e}function D(e){var r,n=e.e;return null===n?e.toString():(r=$(e.c),r=n<=g||i<=n?W(r,n):X(r,n,"0"),e.s<0?"-"+r:r)}return _.clone=e,_.ROUND_UP=0,_.ROUND_DOWN=1,_.ROUND_CEIL=2,_.ROUND_FLOOR=3,_.ROUND_HALF_UP=4,_.ROUND_HALF_DOWN=5,_.ROUND_HALF_EVEN=6,_.ROUND_HALF_CEIL=7,_.ROUND_HALF_FLOOR=8,_.EUCLID=9,_.config=_.set=function(e){var r,n;if(null!=e){if("object"!=typeof e)throw Error(U+"Object expected: "+e);if(e.hasOwnProperty(r="DECIMAL_PLACES")&&(H(n=e[r],0,q,r),y=n),e.hasOwnProperty(r="ROUNDING_MODE")&&(H(n=e[r],0,8,r),N=n),e.hasOwnProperty(r="EXPONENTIAL_AT")&&((n=e[r])&&n.pop?(H(n[0],-q,0,r),H(n[1],0,q,r),g=n[0],i=n[1]):(H(n,-q,q,r),g=-(i=n<0?-n:n))),e.hasOwnProperty(r="RANGE"))if((n=e[r])&&n.pop)H(n[0],-q,-1,r),H(n[1],1,q,r),m=n[0],d=n[1];else{if(H(n,-q,q,r),!n)throw Error(U+r+" cannot be zero: "+n);m=-(d=n<0?-n:n)}if(e.hasOwnProperty(r="CRYPTO")){if((n=e[r])!==!!n)throw Error(U+r+" not true or false: "+n);if(n){if("undefined"==typeof crypto||!crypto||!crypto.getRandomValues&&!crypto.randomBytes)throw O=!n,Error(U+"crypto unavailable");O=n}else O=n}if(e.hasOwnProperty(r="MODULO_MODE")&&(H(n=e[r],0,9,r),o=n),e.hasOwnProperty(r="POW_PRECISION")&&(H(n=e[r],0,q,r),b=n),e.hasOwnProperty(r="FORMAT")){if("object"!=typeof(n=e[r]))throw Error(U+r+" not an object: "+n);E=n}if(e.hasOwnProperty(r="ALPHABET")){if("string"!=typeof(n=e[r])||/^.$|[+-.\s]|(.).*\1/.test(n))throw Error(U+r+" invalid: "+n);A=n}}return{DECIMAL_PLACES:y,ROUNDING_MODE:N,EXPONENTIAL_AT:[g,i],RANGE:[m,d],CRYPTO:O,MODULO_MODE:o,POW_PRECISION:b,FORMAT:E,ALPHABET:A}},_.isBigNumber=function(e){return e instanceof _||e&&!0===e._isBigNumber||!1},_.maximum=_.max=function(){return R(arguments,t.lt)},_.minimum=_.min=function(){return R(arguments,t.gt)},_.random=(n=9007199254740992,l=Math.random()*n&2097151?function(){return T(Math.random()*n)}:function(){return 8388608*(1073741824*Math.random()|0)+(8388608*Math.random()|0)},function(e){var r,n,t,i,o,s=0,f=[],u=new _(w);if(null==e?e=y:H(e,0,q),i=B(e/M),O)if(crypto.getRandomValues){for(r=crypto.getRandomValues(new Uint32Array(i*=2));s<i;)9e15<=(o=131072*r[s]+(r[s+1]>>>11))?(n=crypto.getRandomValues(new Uint32Array(2)),r[s]=n[0],r[s+1]=n[1]):(f.push(o%1e14),s+=2);s=i/2}else{if(!crypto.randomBytes)throw O=!1,Error(U+"crypto unavailable");for(r=crypto.randomBytes(i*=7);s<i;)9e15<=(o=281474976710656*(31&r[s])+1099511627776*r[s+1]+4294967296*r[s+2]+16777216*r[s+3]+(r[s+4]<<16)+(r[s+5]<<8)+r[s+6])?crypto.randomBytes(7).copy(r,s):(f.push(o%1e14),s+=7);s=i/7}if(!O)for(;s<i;) (o=l())<9e15&&(f[s++]=o%1e14);for(i=f[--s],e%=M,i&&e&&(o=F[M-e],f[s]=T(i/o)*o);0===f[s];f.pop(),s--);if(s<0)f=[t=0];else{for(t=-1;0===f[0];f.splice(0,1),t-=M);for(s=1,o=f[0];10<=o;o/=10,s++);s<M&&(t-=M-s)}return u.e=t,u.c=f,u}),_.sum=function(){for(var e=1,r=arguments,n=new _(r[0]);e<r.length;)n=n.plus(r[e++]);return n},a=function(){var m="0123456789";function d(e,r,n,t){for(var i,o,s=[0],f=0,u=e.length;f<u;){for(o=s.length;o--;s[o]*=r);for(s[0]+=t.indexOf(e.charAt(f++)),i=0;i<s.length;i++)s[i]>n-1&&(null==s[i+1]&&(s[i+1]=0),s[i+1]+=s[i]/n|0,s[i]%=n)}return s.reverse()}return function(e,r,n,t,i){var o,s,f,u,l,c,a,h,p=e.indexOf("."),g=y,w=N;for(0<=p&&(u=b,b=0,e=e.replace(".",""),c=(h=new _(r)).pow(e.length-p),b=u,h.c=d(X($(c.c),c.e,"0"),10,n,m),h.e=h.c.length),f=u=(a=d(e,r,n,i?(o=A,m):(o=m,A))).length;0==a[--u];a.pop());if(!a[0])return o.charAt(0);if(p<0?--f:(c.c=a,c.e=f,c.s=t,a=(c=v(c,h,g,w,n)).c,l=c.r,f=c.e),p=a[s=f+g+1],u=n/2,l=l||s<0||null!=a[s+1],l=w<4?(null!=p||l)&&(0==w||w==(c.s<0?3:2)):u<p||p==u&&(4==w||l||6==w&&1&a[s-1]||w==(c.s<0?8:7)),s<1||!a[0])e=l?X(o.charAt(1),-g,o.charAt(0)):o.charAt(0);else{if(a.length=s,l)for(--n;++a[--s]>n;)a[s]=0,s||(++f,a=[1].concat(a));for(u=a.length;!a[--u];);for(p=0,e="";p<=u;e+=o.charAt(a[p++]));e=X(e,f,o.charAt(0))}return e}}(),v=function(){function S(e,r,n){var t,i,o,s,f=0,u=e.length,l=r%k,c=r/k|0;for(e=e.slice();u--;)f=((i=l*(o=e[u]%k)+(t=c*o+(s=e[u]/k|0)*l)%k*k+f)/n|0)+(t/k|0)+c*s,e[u]=i%n;return f&&(e=[f].concat(e)),e}function R(e,r,n,t){var i,o;if(n!=t)o=t<n?1:-1;else for(i=o=0;i<n;i++)if(e[i]!=r[i]){o=e[i]>r[i]?1:-1;break}return o}function P(e,r,n,t){for(var i=0;n--;)e[n]-=i,i=e[n]<r[n]?1:0,e[n]=i*t+e[n]-r[n];for(;!e[0]&&1<e.length;e.splice(0,1));}return function(e,r,n,t,i){var o,s,f,u,l,c,a,h,p,g,w,m,d,v,y,N,O,b=e.s==r.s?1:-1,E=e.c,A=r.c;if(!(E&&E[0]&&A&&A[0]))return new _(e.s&&r.s&&(E?!A||E[0]!=A[0]:A)?E&&0==E[0]||!A?0*b:b/0:NaN);for(p=(h=new _(b)).c=[],b=n+(s=e.e-r.e)+1,i||(i=C,s=j(e.e/M)-j(r.e/M),b=b/M|0),f=0;A[f]==(E[f]||0);f++);if(A[f]>(E[f]||0)&&s--,b<0)p.push(1),u=!0;else{for(v=E.length,N=A.length,b+=2,1<(l=T(i/(A[f=0]+1)))&&(A=S(A,l,i),E=S(E,l,i),N=A.length,v=E.length),d=N,w=(g=E.slice(0,N)).length;w<N;g[w++]=0);O=A.slice(),O=[0].concat(O),y=A[0],A[1]>=i/2&&y++;do{if(l=0,(o=R(A,g,N,w))<0){if(m=g[0],N!=w&&(m=m*i+(g[1]||0)),1<(l=T(m/y)))for(i<=l&&(l=i-1),a=(c=S(A,l,i)).length,w=g.length;1==R(c,g,a,w);)l--,P(c,N<a?O:A,a,i),a=c.length,o=1;else 0==l&&(o=l=1),a=(c=A.slice()).length;if(a<w&&(c=[0].concat(c)),P(g,c,w,i),w=g.length,-1==o)for(;R(A,g,N,w)<1;)l++,P(g,N<w?O:A,w,i),w=g.length}else 0===o&&(l++,g=[0]);p[f++]=l,g[0]?g[w++]=E[d]||0:(g=[E[d]],w=1)}while((d++<v||null!=g[0])&&b--);u=null!=g[0],p[0]||p.splice(0,1)}if(i==C){for(f=1,b=p[0];10<=b;b/=10,f++);x(h,n+(h.e=f+s*M-1)+1,t,u)}else h.e=s,h.r=+u;return h}}(),s=/^(-?)0([xbo])(?=\w[\w.]*$)/i,f=/^([^.]+)\.$/,u=/^\.([^.]+)$/,c=/^-?(Infinity|NaN)$/,p=/^\s*\+(?=[\w.])|^\s+|\s+$/g,h=function(e,r,n,t){var i,o=n?r:r.replace(p,"");if(c.test(o))e.s=isNaN(o)?null:o<0?-1:1,e.c=e.e=null;else{if(!n&&(o=o.replace(s,function(e,r,n){return i="x"==(n=n.toLowerCase())?16:"b"==n?2:8,t&&t!=i?e:r}),t&&(i=t,o=o.replace(f,"$1").replace(u,"0.$1")),r!=o))return new _(o,i);if(_.DEBUG)throw Error(U+"Not a"+(t?" base "+t:"")+" number: "+r);e.c=e.e=e.s=null}},t.absoluteValue=t.abs=function(){var e=new _(this);return e.s<0&&(e.s=1),e},t.comparedTo=function(e,r){return z(this,new _(e,r))},t.decimalPlaces=t.dp=function(e,r){var n,t,i;if(null!=e)return H(e,0,q),null==r?r=N:H(r,0,8),x(new _(this),e+this.e+1,r);if(!(n=this.c))return null;if(t=((i=n.length-1)-j(this.e/M))*M,i=n[i])for(;i%10==0;i/=10,t--);return t<0&&(t=0),t},t.dividedBy=t.div=function(e,r){return v(this,new _(e,r),y,N)},t.dividedToIntegerBy=t.idiv=function(e,r){return v(this,new _(e,r),0,1)},t.exponentiatedBy=t.pow=function(e,r){var n,t,i,o,s,f,u,l,c=this;if((e=new _(e)).c&&!e.isInteger())throw Error(U+"Exponent not an integer: "+D(e));if(null!=r&&(r=new _(r)),s=14<e.e,!c.c||!c.c[0]||1==c.c[0]&&!c.e&&1==c.c.length||!e.c||!e.c[0])return l=new _(Math.pow(+D(c),s?2-V(e):+D(e))),r?l.mod(r):l;if(f=e.s<0,r){if(r.c?!r.c[0]:!r.s)return new _(NaN);(t=!f&&c.isInteger()&&r.isInteger())&&(c=c.mod(r))}else{if(9<e.e&&(0<c.e||c.e<-1||(0==c.e?1<c.c[0]||s&&24e7<=c.c[1]:c.c[0]<8e13||s&&c.c[0]<=9999975e7)))return o=c.s<0&&V(e)?-0:0,-1<c.e&&(o=1/o),new _(f?1/o:o);b&&(o=B(b/M+2))}for(u=s?(n=new _(.5),f&&(e.s=1),V(e)):(i=Math.abs(+D(e)))%2,l=new _(w);;){if(u){if(!(l=l.times(c)).c)break;o?l.c.length>o&&(l.c.length=o):t&&(l=l.mod(r))}if(i){if(0===(i=T(i/2)))break;u=i%2}else if(x(e=e.times(n),e.e+1,1),14<e.e)u=V(e);else{if(0==(i=+D(e)))break;u=i%2}c=c.times(c),o?c.c&&c.c.length>o&&(c.c.length=o):t&&(c=c.mod(r))}return t?l:(f&&(l=w.div(l)),r?l.mod(r):o?x(l,b,N,void 0):l)},t.integerValue=function(e){var r=new _(this);return null==e?e=N:H(e,0,8),x(r,r.e+1,e)},t.isEqualTo=t.eq=function(e,r){return 0===z(this,new _(e,r))},t.isFinite=function(){return!!this.c},t.isGreaterThan=t.gt=function(e,r){return 0<z(this,new _(e,r))},t.isGreaterThanOrEqualTo=t.gte=function(e,r){return 1===(r=z(this,new _(e,r)))||0===r},t.isInteger=function(){return!!this.c&&j(this.e/M)>this.c.length-2},t.isLessThan=t.lt=function(e,r){return z(this,new _(e,r))<0},t.isLessThanOrEqualTo=t.lte=function(e,r){return-1===(r=z(this,new _(e,r)))||0===r},t.isNaN=function(){return!this.s},t.isNegative=function(){return this.s<0},t.isPositive=function(){return 0<this.s},t.isZero=function(){return!!this.c&&0==this.c[0]},t.minus=function(e,r){var n,t,i,o,s=this,f=s.s;if(r=(e=new _(e,r)).s,!f||!r)return new _(NaN);if(f!=r)return e.s=-r,s.plus(e);var u=s.e/M,l=e.e/M,c=s.c,a=e.c;if(!u||!l){if(!c||!a)return c?(e.s=-r,e):new _(a?s:NaN);if(!c[0]||!a[0])return a[0]?(e.s=-r,e):new _(c[0]?s:3==N?-0:0)}if(u=j(u),l=j(l),c=c.slice(),f=u-l){for((i=(o=f<0)?(f=-f,c):(l=u,a)).reverse(),r=f;r--;i.push(0));i.reverse()}else for(t=(o=(f=c.length)<(r=a.length))?f:r,f=r=0;r<t;r++)if(c[r]!=a[r]){o=c[r]<a[r];break}if(o&&(i=c,c=a,a=i,e.s=-e.s),0<(r=(t=a.length)-(n=c.length)))for(;r--;c[n++]=0);for(r=C-1;f<t;){if(c[--t]<a[t]){for(n=t;n&&!c[--n];c[n]=r);--c[n],c[t]+=C}c[t]-=a[t]}for(;0==c[0];c.splice(0,1),--l);return c[0]?P(e,c,l):(e.s=3==N?-1:1,e.c=[e.e=0],e)},t.modulo=t.mod=function(e,r){var n,t,i=this;return e=new _(e,r),!i.c||!e.s||e.c&&!e.c[0]?new _(NaN):!e.c||i.c&&!i.c[0]?new _(i):(9==o?(t=e.s,e.s=1,n=v(i,e,0,3),e.s=t,n.s*=t):n=v(i,e,0,o),(e=i.minus(n.times(e))).c[0]||1!=o||(e.s=i.s),e)},t.multipliedBy=t.times=function(e,r){var n,t,i,o,s,f,u,l,c,a,h,p,g,w,m,d=this,v=d.c,y=(e=new _(e,r)).c;if(!(v&&y&&v[0]&&y[0]))return!d.s||!e.s||v&&!v[0]&&!y||y&&!y[0]&&!v?e.c=e.e=e.s=null:(e.s*=d.s,v&&y?(e.c=[0],e.e=0):e.c=e.e=null),e;for(t=j(d.e/M)+j(e.e/M),e.s*=d.s,(u=v.length)<(a=y.length)&&(g=v,v=y,y=g,i=u,u=a,a=i),i=u+a,g=[];i--;g.push(0));for(w=C,m=k,i=a;0<=--i;){for(n=0,h=y[i]%m,p=y[i]/m|0,o=i+(s=u);i<o;)n=((l=h*(l=v[--s]%m)+(f=p*l+(c=v[s]/m|0)*h)%m*m+g[o]+n)/w|0)+(f/m|0)+p*c,g[o--]=l%w;g[o]=n}return n?++t:g.splice(0,1),P(e,g,t)},t.negated=function(){var e=new _(this);return e.s=-e.s||null,e},t.plus=function(e,r){var n,t=this,i=t.s;if(r=(e=new _(e,r)).s,!i||!r)return new _(NaN);if(i!=r)return e.s=-r,t.minus(e);var o=t.e/M,s=e.e/M,f=t.c,u=e.c;if(!o||!s){if(!f||!u)return new _(i/0);if(!f[0]||!u[0])return u[0]?e:new _(f[0]?t:0*i)}if(o=j(o),s=j(s),f=f.slice(),i=o-s){for((n=0<i?(s=o,u):(i=-i,f)).reverse();i--;n.push(0));n.reverse()}for((i=f.length)-(r=u.length)<0&&(n=u,u=f,f=n,r=i),i=0;r;)i=(f[--r]=f[r]+u[r]+i)/C|0,f[r]=C===f[r]?0:f[r]%C;return i&&(f=[i].concat(f),++s),P(e,f,s)},t.precision=t.sd=function(e,r){var n,t,i;if(null!=e&&e!==!!e)return H(e,1,q),null==r?r=N:H(r,0,8),x(new _(this),e,r);if(!(n=this.c))return null;if(t=(i=n.length-1)*M+1,i=n[i]){for(;i%10==0;i/=10,t--);for(i=n[0];10<=i;i/=10,t++);}return e&&this.e+1>t&&(t=this.e+1),t},t.shiftedBy=function(e){return H(e,-G,G),this.times("1e"+e)},t.squareRoot=t.sqrt=function(){var e,r,n,t,i,o=this,s=o.c,f=o.s,u=o.e,l=y+4,c=new _("0.5");if(1!==f||!s||!s[0])return new _(!f||f<0&&(!s||s[0])?NaN:s?o:1/0);if((n=0==(f=Math.sqrt(+D(o)))||f==1/0?(((r=$(s)).length+u)%2==0&&(r+="0"),f=Math.sqrt(+r),u=j((u+1)/2)-(u<0||u%2),new _(r=f==1/0?"1e"+u:(r=f.toExponential()).slice(0,r.indexOf("e")+1)+u)):new _(f+"")).c[0])for((f=(u=n.e)+l)<3&&(f=0);;)if(i=n,n=c.times(i.plus(v(o,i,l,1))),$(i.c).slice(0,f)===(r=$(n.c)).slice(0,f)){if(n.e<u&&--f,"9999"!=(r=r.slice(f-3,f+1))&&(t||"4999"!=r)){+r&&(+r.slice(1)||"5"!=r.charAt(0))||(x(n,n.e+y+2,1),e=!n.times(n).eq(o));break}if(!t&&(x(i,i.e+y+2,0),i.times(i).eq(o))){n=i;break}l+=4,f+=4,t=1}return x(n,n.e+y+1,N,e)},t.toExponential=function(e,r){return null!=e&&(H(e,0,q),e++),S(this,e,r,1)},t.toFixed=function(e,r){return null!=e&&(H(e,0,q),e=e+this.e+1),S(this,e,r)},t.toFormat=function(e,r,n){var t;if(null==n)null!=e&&r&&"object"==typeof r?(n=r,r=null):e&&"object"==typeof e?(n=e,e=r=null):n=E;else if("object"!=typeof n)throw Error(U+"Argument not an object: "+n);if(t=this.toFixed(e,r),this.c){var i,o=t.split("."),s=+n.groupSize,f=+n.secondaryGroupSize,u=n.groupSeparator||"",l=o[0],c=o[1],a=this.s<0,h=a?l.slice(1):l,p=h.length;if(f&&(i=s,s=f,p-=f=i),0<s&&0<p){for(i=p%s||s,l=h.substr(0,i);i<p;i+=s)l+=u+h.substr(i,s);0<f&&(l+=u+h.slice(i)),a&&(l="-"+l)}t=c?l+(n.decimalSeparator||"")+((f=+n.fractionGroupSize)?c.replace(new RegExp("\\d{"+f+"}\\B","g"),"$&"+(n.fractionGroupSeparator||"")):c):l}return(n.prefix||"")+t+(n.suffix||"")},t.toFraction=function(e){var r,n,t,i,o,s,f,u,l,c,a,h,p=this,g=p.c;if(null!=e&&(!(f=new _(e)).isInteger()&&(f.c||1!==f.s)||f.lt(w)))throw Error(U+"Argument "+(f.isInteger()?"out of range: ":"not an integer: ")+D(f));if(!g)return new _(p);for(r=new _(w),l=n=new _(w),t=u=new _(w),h=$(g),o=r.e=h.length-p.e-1,r.c[0]=F[(s=o%M)<0?M+s:s],e=!e||0<f.comparedTo(r)?0<o?r:l:f,s=d,d=1/0,f=new _(h),u.c[0]=0;c=v(f,r,0,1),1!=(i=n.plus(c.times(t))).comparedTo(e);)n=t,t=i,l=u.plus(c.times(i=l)),u=i,r=f.minus(c.times(i=r)),f=i;return i=v(e.minus(n),t,0,1),u=u.plus(i.times(l)),n=n.plus(i.times(t)),u.s=l.s=p.s,a=v(l,t,o*=2,N).minus(p).abs().comparedTo(v(u,n,o,N).minus(p).abs())<1?[l,t]:[u,n],d=s,a},t.toNumber=function(){return+D(this)},t.toPrecision=function(e,r){return null!=e&&H(e,1,q),S(this,e,r,2)},t.toString=function(e){var r,n=this.s,t=this.e;return null===t?n?(r="Infinity",n<0&&(r="-"+r)):r="NaN":(r=$(this.c),r=null==e?t<=g||i<=t?W(r,t):X(r,t,"0"):(H(e,2,A.length,"Base"),a(X(r,t,"0"),10,e,n,!0)),n<0&&this.c[0]&&(r="-"+r)),r},t.valueOf=t.toJSON=function(){return D(this)},t._isBigNumber=!0,"function"==typeof Symbol&&"symbol"==typeof Symbol.iterator&&(t[Symbol.toStringTag]="BigNumber",t[Symbol.for("nodejs.util.inspect.custom")]=t.valueOf),null!=r&&_.set(r),_}()).default=r.BigNumber=r,"function"==typeof define&&define.amd?define(function(){return r}):"undefined"!=typeof module&&module.exports?module.exports=r:(e||(e="undefined"!=typeof self&&self?self:window),e.BigNumber=r)}(this);

const readline = require('readline');
const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
});
!function(e){"use strict";var r,L=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,B=Math.ceil,T=Math.floor,U="[BigNumber Error] ",I=U+"Number primitive has more than 15 significant digits: ",C=1e14,M=14,G=9007199254740991,F=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],k=1e7,q=1e9;function j(e){var r=0|e;return 0<e||e===r?r:r-1}function $(e){for(var r,n,t=1,i=e.length,o=e[0]+"";t<i;){for(r=e[t++]+"",n=M-r.length;n--;r="0"+r);o+=r}for(i=o.length;48===o.charCodeAt(--i););return o.slice(0,i+1||1)}function z(e,r){var n,t,i=e.c,o=r.c,s=e.s,f=r.s,u=e.e,l=r.e;if(!s||!f)return null;if(n=i&&!i[0],t=o&&!o[0],n||t)return n?t?0:-f:s;if(s!=f)return s;if(n=s<0,t=u==l,!i||!o)return t?0:!i^n?1:-1;if(!t)return l<u^n?1:-1;for(f=(u=i.length)<(l=o.length)?u:l,s=0;s<f;s++)if(i[s]!=o[s])return i[s]>o[s]^n?1:-1;return u==l?0:l<u^n?1:-1}function H(e,r,n,t){if(e<r||n<e||e!==(e<0?B(e):T(e)))throw Error(U+(t||"Argument")+("number"==typeof e?e<r||n<e?" out of range: ":" not an integer: ":" not a primitive number: ")+String(e))}function V(e){var r=e.c.length-1;return j(e.e/M)==r&&e.c[r]%2!=0}function W(e,r){return(1<e.length?e.charAt(0)+"."+e.slice(1):e)+(r<0?"e":"e+")+r}function X(e,r,n){var t,i;if(r<0){for(i=n+".";++r;i+=n);e=i+e}else if(++r>(t=e.length)){for(i=n,r-=t;--r;i+=n);e+=i}else r<t&&(e=e.slice(0,r)+"."+e.slice(r));return e}(r=function e(r){var v,a,h,n,l,s,f,u,c,p,t=_.prototype={constructor:_,toString:null,valueOf:null},w=new _(1),y=20,N=4,g=-7,i=21,m=-1e7,d=1e7,O=!1,o=1,b=0,E={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:" ",suffix:""},A="0123456789abcdefghijklmnopqrstuvwxyz";function _(e,r){var n,t,i,o,s,f,u,l,c=this;if(!(c instanceof _))return new _(e,r);if(null==r){if(e instanceof _)return c.s=e.s,c.e=e.e,void(c.c=(e=e.c)?e.slice():e);if((f="number"==typeof e)&&0*e==0){if(c.s=1/e<0?(e=-e,-1):1,e===~~e){for(o=0,s=e;10<=s;s/=10,o++);return c.e=o,void(c.c=[e])}l=String(e)}else{if(l=String(e),!L.test(l))return h(c,l,f);c.s=45==l.charCodeAt(0)?(l=l.slice(1),-1):1}-1<(o=l.indexOf("."))&&(l=l.replace(".","")),0<(s=l.search(/e/i))?(o<0&&(o=s),o+=+l.slice(s+1),l=l.substring(0,s)):o<0&&(o=l.length)}else{if(H(r,2,A.length,"Base"),l=String(e),10==r)return x(c=new _(e instanceof _?e:l),y+c.e+1,N);if(f="number"==typeof e){if(0*e!=0)return h(c,l,f,r);if(c.s=1/e<0?(l=l.slice(1),-1):1,_.DEBUG&&15<l.replace(/^0\.0*|\./,"").length)throw Error(I+e);f=!1}else c.s=45===l.charCodeAt(0)?(l=l.slice(1),-1):1;for(n=A.slice(0,r),o=s=0,u=l.length;s<u;s++)if(n.indexOf(t=l.charAt(s))<0){if("."==t){if(o<s){o=u;continue}}else if(!i&&(l==l.toUpperCase()&&(l=l.toLowerCase())||l==l.toLowerCase()&&(l=l.toUpperCase()))){i=!0,s=-1,o=0;continue}return h(c,String(e),f,r)}-1<(o=(l=a(l,r,10,c.s)).indexOf("."))?l=l.replace(".",""):o=l.length}for(s=0;48===l.charCodeAt(s);s++);for(u=l.length;48===l.charCodeAt(--u););if(l=l.slice(s,++u)){if(u-=s,f&&_.DEBUG&&15<u&&(G<e||e!==T(e)))throw Error(I+c.s*e);if(d<(o=o-s-1))c.c=c.e=null;else if(o<m)c.c=[c.e=0];else{if(c.e=o,c.c=[],s=(o+1)%M,o<0&&(s+=M),s<u){for(s&&c.c.push(+l.slice(0,s)),u-=M;s<u;)c.c.push(+l.slice(s,s+=M));l=l.slice(s),s=M-l.length}else s-=u;for(;s--;l+="0");c.c.push(+l)}}else c.c=[c.e=0]}function S(e,r,n,t){var i,o,s,f,u;if(null==n?n=N:H(n,0,8),!e.c)return e.toString();if(i=e.c[0],s=e.e,null==r)u=$(e.c),u=1==t||2==t&&s<=g?W(u,s):X(u,s,"0");else if(o=(e=x(new _(e),r,n)).e,f=(u=$(e.c)).length,1==t||2==t&&(r<=o||o<=g)){for(;f<r;u+="0",f++);u=W(u,o)}else if(r-=s,u=X(u,o,"0"),f<o+1){if(0<--r)for(u+=".";r--;u+="0");}else if(0<(r+=o-f))for(o+1==f&&(u+=".");r--;u+="0");return e.s<0&&i?"-"+u:u}function R(e,r){for(var n,t=1,i=new _(e[0]);t<e.length;t++){if(!(n=new _(e[t])).s){i=n;break}r.call(i,n)&&(i=n)}return i}function P(e,r,n){for(var t=1,i=r.length;!r[--i];r.pop());for(i=r[0];10<=i;i/=10,t++);return(n=t+n*M-1)>d?e.c=e.e=null:e.c=n<m?[e.e=0]:(e.e=n,r),e}function x(e,r,n,t){var i,o,s,f,u,l,c,a=e.c,h=F;if(a){e:{for(i=1,f=a[0];10<=f;f/=10,i++);if((o=r-i)<0)o+=M,s=r,c=(u=a[l=0])/h[i-s-1]%10|0;else if((l=B((o+1)/M))>=a.length){if(!t)break e;for(;a.length<=l;a.push(0));u=c=0,s=(o%=M)-M+(i=1)}else{for(u=f=a[l],i=1;10<=f;f/=10,i++);c=(s=(o%=M)-M+i)<0?0:u/h[i-s-1]%10|0}if(t=t||r<0||null!=a[l+1]||(s<0?u:u%h[i-s-1]),t=n<4?(c||t)&&(0==n||n==(e.s<0?3:2)):5<c||5==c&&(4==n||t||6==n&&(0<o?0<s?u/h[i-s]:0:a[l-1])%10&1||n==(e.s<0?8:7)),r<1||!a[0])return a.length=0,t?(r-=e.e+1,a[0]=h[(M-r%M)%M],e.e=-r||0):a[0]=e.e=0,e;if(0==o?(a.length=l,f=1,l--):(a.length=l+1,f=h[M-o],a[l]=0<s?T(u/h[i-s]%h[s])*f:0),t)for(;;){if(0==l){for(o=1,s=a[0];10<=s;s/=10,o++);for(s=a[0]+=f,f=1;10<=s;s/=10,f++);o!=f&&(e.e++,a[0]==C&&(a[0]=1));break} if(a[l]+=f,a[l]!=C)break;a[l--]=0,f=1}for(o=a.length;0===a[--o];a.pop());}e.e>d?e.c=e.e=null:e.e<m&&(e.c=[e.e=0])}return e}function D(e){var r,n=e.e;return null===n?e.toString():(r=$(e.c),r=n<=g||i<=n?W(r,n):X(r,n,"0"),e.s<0?"-"+r:r)}return _.clone=e,_.ROUND_UP=0,_.ROUND_DOWN=1,_.ROUND_CEIL=2,_.ROUND_FLOOR=3,_.ROUND_HALF_UP=4,_.ROUND_HALF_DOWN=5,_.ROUND_HALF_EVEN=6,_.ROUND_HALF_CEIL=7,_.ROUND_HALF_FLOOR=8,_.EUCLID=9,_.config=_.set=function(e){var r,n;if(null!=e){if("object"!=typeof e)throw Error(U+"Object expected: "+e);if(e.hasOwnProperty(r="DECIMAL_PLACES")&&(H(n=e[r],0,q,r),y=n),e.hasOwnProperty(r="ROUNDING_MODE")&&(H(n=e[r],0,8,r),N=n),e.hasOwnProperty(r="EXPONENTIAL_AT")&&((n=e[r])&&n.pop?(H(n[0],-q,0,r),H(n[1],0,q,r),g=n[0],i=n[1]):(H(n,-q,q,r),g=-(i=n<0?-n:n))),e.hasOwnProperty(r="RANGE"))if((n=e[r])&&n.pop)H(n[0],-q,-1,r),H(n[1],1,q,r),m=n[0],d=n[1];else{if(H(n,-q,q,r),!n)throw Error(U+r+" cannot be zero: "+n);m=-(d=n<0?-n:n)}if(e.hasOwnProperty(r="CRYPTO")){if((n=e[r])!==!!n)throw Error(U+r+" not true or false: "+n);if(n){if("undefined"==typeof crypto||!crypto||!crypto.getRandomValues&&!crypto.randomBytes)throw O=!n,Error(U+"crypto unavailable");O=n}else O=n}if(e.hasOwnProperty(r="MODULO_MODE")&&(H(n=e[r],0,9,r),o=n),e.hasOwnProperty(r="POW_PRECISION")&&(H(n=e[r],0,q,r),b=n),e.hasOwnProperty(r="FORMAT")){if("object"!=typeof(n=e[r]))throw Error(U+r+" not an object: "+n);E=n}if(e.hasOwnProperty(r="ALPHABET")){if("string"!=typeof(n=e[r])||/^.$|[+-.\s]|(.).*\1/.test(n))throw Error(U+r+" invalid: "+n);A=n}}return{DECIMAL_PLACES:y,ROUNDING_MODE:N,EXPONENTIAL_AT:[g,i],RANGE:[m,d],CRYPTO:O,MODULO_MODE:o,POW_PRECISION:b,FORMAT:E,ALPHABET:A}},_.isBigNumber=function(e){return e instanceof _||e&&!0===e._isBigNumber||!1},_.maximum=_.max=function(){return R(arguments,t.lt)},_.minimum=_.min=function(){return R(arguments,t.gt)},_.random=(n=9007199254740992,l=Math.random()*n&2097151?function(){return T(Math.random()*n)}:function(){return 8388608*(1073741824*Math.random()|0)+(8388608*Math.random()|0)},function(e){var r,n,t,i,o,s=0,f=[],u=new _(w);if(null==e?e=y:H(e,0,q),i=B(e/M),O)if(crypto.getRandomValues){for(r=crypto.getRandomValues(new Uint32Array(i*=2));s<i;)9e15<=(o=131072*r[s]+(r[s+1]>>>11))?(n=crypto.getRandomValues(new Uint32Array(2)),r[s]=n[0],r[s+1]=n[1]):(f.push(o%1e14),s+=2);s=i/2}else{if(!crypto.randomBytes)throw O=!1,Error(U+"crypto unavailable");for(r=crypto.randomBytes(i*=7);s<i;)9e15<=(o=281474976710656*(31&r[s])+1099511627776*r[s+1]+4294967296*r[s+2]+16777216*r[s+3]+(r[s+4]<<16)+(r[s+5]<<8)+r[s+6])?crypto.randomBytes(7).copy(r,s):(f.push(o%1e14),s+=7);s=i/7}if(!O)for(;s<i;) (o=l())<9e15&&(f[s++]=o%1e14);for(i=f[--s],e%=M,i&&e&&(o=F[M-e],f[s]=T(i/o)*o);0===f[s];f.pop(),s--);if(s<0)f=[t=0];else{for(t=-1;0===f[0];f.splice(0,1),t-=M);for(s=1,o=f[0];10<=o;o/=10,s++);s<M&&(t-=M-s)}return u.e=t,u.c=f,u}),_.sum=function(){for(var e=1,r=arguments,n=new _(r[0]);e<r.length;)n=n.plus(r[e++]);return n},a=function(){var m="0123456789";function d(e,r,n,t){for(var i,o,s=[0],f=0,u=e.length;f<u;){for(o=s.length;o--;s[o]*=r);for(s[0]+=t.indexOf(e.charAt(f++)),i=0;i<s.length;i++)s[i]>n-1&&(null==s[i+1]&&(s[i+1]=0),s[i+1]+=s[i]/n|0,s[i]%=n)}return s.reverse()}return function(e,r,n,t,i){var o,s,f,u,l,c,a,h,p=e.indexOf("."),g=y,w=N;for(0<=p&&(u=b,b=0,e=e.replace(".",""),c=(h=new _(r)).pow(e.length-p),b=u,h.c=d(X($(c.c),c.e,"0"),10,n,m),h.e=h.c.length),f=u=(a=d(e,r,n,i?(o=A,m):(o=m,A))).length;0==a[--u];a.pop());if(!a[0])return o.charAt(0);if(p<0?--f:(c.c=a,c.e=f,c.s=t,a=(c=v(c,h,g,w,n)).c,l=c.r,f=c.e),p=a[s=f+g+1],u=n/2,l=l||s<0||null!=a[s+1],l=w<4?(null!=p||l)&&(0==w||w==(c.s<0?3:2)):u<p||p==u&&(4==w||l||6==w&&1&a[s-1]||w==(c.s<0?8:7)),s<1||!a[0])e=l?X(o.charAt(1),-g,o.charAt(0)):o.charAt(0);else{if(a.length=s,l)for(--n;++a[--s]>n;)a[s]=0,s||(++f,a=[1].concat(a));for(u=a.length;!a[--u];);for(p=0,e="";p<=u;e+=o.charAt(a[p++]));e=X(e,f,o.charAt(0))}return e}}(),v=function(){function S(e,r,n){var t,i,o,s,f=0,u=e.length,l=r%k,c=r/k|0;for(e=e.slice();u--;)f=((i=l*(o=e[u]%k)+(t=c*o+(s=e[u]/k|0)*l)%k*k+f)/n|0)+(t/k|0)+c*s,e[u]=i%n;return f&&(e=[f].concat(e)),e}function R(e,r,n,t){var i,o;if(n!=t)o=t<n?1:-1;else for(i=o=0;i<n;i++)if(e[i]!=r[i]){o=e[i]>r[i]?1:-1;break}return o}function P(e,r,n,t){for(var i=0;n--;)e[n]-=i,i=e[n]<r[n]?1:0,e[n]=i*t+e[n]-r[n];for(;!e[0]&&1<e.length;e.splice(0,1));}return function(e,r,n,t,i){var o,s,f,u,l,c,a,h,p,g,w,m,d,v,y,N,O,b=e.s==r.s?1:-1,E=e.c,A=r.c;if(!(E&&E[0]&&A&&A[0]))return new _(e.s&&r.s&&(E?!A||E[0]!=A[0]:A)?E&&0==E[0]||!A?0*b:b/0:NaN);for(p=(h=new _(b)).c=[],b=n+(s=e.e-r.e)+1,i||(i=C,s=j(e.e/M)-j(r.e/M),b=b/M|0),f=0;A[f]==(E[f]||0);f++);if(A[f]>(E[f]||0)&&s--,b<0)p.push(1),u=!0;else{for(v=E.length,N=A.length,b+=2,1<(l=T(i/(A[f=0]+1)))&&(A=S(A,l,i),E=S(E,l,i),N=A.length,v=E.length),d=N,w=(g=E.slice(0,N)).length;w<N;g[w++]=0);O=A.slice(),O=[0].concat(O),y=A[0],A[1]>=i/2&&y++;do{if(l=0,(o=R(A,g,N,w))<0){if(m=g[0],N!=w&&(m=m*i+(g[1]||0)),1<(l=T(m/y)))for(i<=l&&(l=i-1),a=(c=S(A,l,i)).length,w=g.length;1==R(c,g,a,w);)l--,P(c,N<a?O:A,a,i),a=c.length,o=1;else 0==l&&(o=l=1),a=(c=A.slice()).length;if(a<w&&(c=[0].concat(c)),P(g,c,w,i),w=g.length,-1==o)for(;R(A,g,N,w)<1;)l++,P(g,N<w?O:A,w,i),w=g.length}else 0===o&&(l++,g=[0]);p[f++]=l,g[0]?g[w++]=E[d]||0:(g=[E[d]],w=1)}while((d++<v||null!=g[0])&&b--);u=null!=g[0],p[0]||p.splice(0,1)}if(i==C){for(f=1,b=p[0];10<=b;b/=10,f++);x(h,n+(h.e=f+s*M-1)+1,t,u)}else h.e=s,h.r=+u;return h}}(),s=/^(-?)0([xbo])(?=\w[\w.]*$)/i,f=/^([^.]+)\.$/,u=/^\.([^.]+)$/,c=/^-?(Infinity|NaN)$/,p=/^\s*\+(?=[\w.])|^\s+|\s+$/g,h=function(e,r,n,t){var i,o=n?r:r.replace(p,"");if(c.test(o))e.s=isNaN(o)?null:o<0?-1:1,e.c=e.e=null;else{if(!n&&(o=o.replace(s,function(e,r,n){return i="x"==(n=n.toLowerCase())?16:"b"==n?2:8,t&&t!=i?e:r}),t&&(i=t,o=o.replace(f,"$1").replace(u,"0.$1")),r!=o))return new _(o,i);if(_.DEBUG)throw Error(U+"Not a"+(t?" base "+t:"")+" number: "+r);e.c=e.e=e.s=null}},t.absoluteValue=t.abs=function(){var e=new _(this);return e.s<0&&(e.s=1),e},t.comparedTo=function(e,r){return z(this,new _(e,r))},t.decimalPlaces=t.dp=function(e,r){var n,t,i;if(null!=e)return H(e,0,q),null==r?r=N:H(r,0,8),x(new _(this),e+this.e+1,r);if(!(n=this.c))return null;if(t=((i=n.length-1)-j(this.e/M))*M,i=n[i])for(;i%10==0;i/=10,t--);return t<0&&(t=0),t},t.dividedBy=t.div=function(e,r){return v(this,new _(e,r),y,N)},t.dividedToIntegerBy=t.idiv=function(e,r){return v(this,new _(e,r),0,1)},t.exponentiatedBy=t.pow=function(e,r){var n,t,i,o,s,f,u,l,c=this;if((e=new _(e)).c&&!e.isInteger())throw Error(U+"Exponent not an integer: "+D(e));if(null!=r&&(r=new _(r)),s=14<e.e,!c.c||!c.c[0]||1==c.c[0]&&!c.e&&1==c.c.length||!e.c||!e.c[0])return l=new _(Math.pow(+D(c),s?2-V(e):+D(e))),r?l.mod(r):l;if(f=e.s<0,r){if(r.c?!r.c[0]:!r.s)return new _(NaN);(t=!f&&c.isInteger()&&r.isInteger())&&(c=c.mod(r))}else{if(9<e.e&&(0<c.e||c.e<-1||(0==c.e?1<c.c[0]||s&&24e7<=c.c[1]:c.c[0]<8e13||s&&c.c[0]<=9999975e7)))return o=c.s<0&&V(e)?-0:0,-1<c.e&&(o=1/o),new _(f?1/o:o);b&&(o=B(b/M+2))}for(u=s?(n=new _(.5),f&&(e.s=1),V(e)):(i=Math.abs(+D(e)))%2,l=new _(w);;){if(u){if(!(l=l.times(c)).c)break;o?l.c.length>o&&(l.c.length=o):t&&(l=l.mod(r))}if(i){if(0===(i=T(i/2)))break;u=i%2}else if(x(e=e.times(n),e.e+1,1),14<e.e)u=V(e);else{if(0==(i=+D(e)))break;u=i%2}c=c.times(c),o?c.c&&c.c.length>o&&(c.c.length=o):t&&(c=c.mod(r))}return t?l:(f&&(l=w.div(l)),r?l.mod(r):o?x(l,b,N,void 0):l)},t.integerValue=function(e){var r=new _(this);return null==e?e=N:H(e,0,8),x(r,r.e+1,e)},t.isEqualTo=t.eq=function(e,r){return 0===z(this,new _(e,r))},t.isFinite=function(){return!!this.c},t.isGreaterThan=t.gt=function(e,r){return 0<z(this,new _(e,r))},t.isGreaterThanOrEqualTo=t.gte=function(e,r){return 1===(r=z(this,new _(e,r)))||0===r},t.isInteger=function(){return!!this.c&&j(this.e/M)>this.c.length-2},t.isLessThan=t.lt=function(e,r){return z(this,new _(e,r))<0},t.isLessThanOrEqualTo=t.lte=function(e,r){return-1===(r=z(this,new _(e,r)))||0===r},t.isNaN=function(){return!this.s},t.isNegative=function(){return this.s<0},t.isPositive=function(){return 0<this.s},t.isZero=function(){return!!this.c&&0==this.c[0]},t.minus=function(e,r){var n,t,i,o,s=this,f=s.s;if(r=(e=new _(e,r)).s,!f||!r)return new _(NaN);if(f!=r)return e.s=-r,s.plus(e);var u=s.e/M,l=e.e/M,c=s.c,a=e.c;if(!u||!l){if(!c||!a)return c?(e.s=-r,e):new _(a?s:NaN);if(!c[0]||!a[0])return a[0]?(e.s=-r,e):new _(c[0]?s:3==N?-0:0)}if(u=j(u),l=j(l),c=c.slice(),f=u-l){for((i=(o=f<0)?(f=-f,c):(l=u,a)).reverse(),r=f;r--;i.push(0));i.reverse()}else for(t=(o=(f=c.length)<(r=a.length))?f:r,f=r=0;r<t;r++)if(c[r]!=a[r]){o=c[r]<a[r];break}if(o&&(i=c,c=a,a=i,e.s=-e.s),0<(r=(t=a.length)-(n=c.length)))for(;r--;c[n++]=0);for(r=C-1;f<t;){if(c[--t]<a[t]){for(n=t;n&&!c[--n];c[n]=r);--c[n],c[t]+=C}c[t]-=a[t]}for(;0==c[0];c.splice(0,1),--l);return c[0]?P(e,c,l):(e.s=3==N?-1:1,e.c=[e.e=0],e)},t.modulo=t.mod=function(e,r){var n,t,i=this;return e=new _(e,r),!i.c||!e.s||e.c&&!e.c[0]?new _(NaN):!e.c||i.c&&!i.c[0]?new _(i):(9==o?(t=e.s,e.s=1,n=v(i,e,0,3),e.s=t,n.s*=t):n=v(i,e,0,o),(e=i.minus(n.times(e))).c[0]||1!=o||(e.s=i.s),e)},t.multipliedBy=t.times=function(e,r){var n,t,i,o,s,f,u,l,c,a,h,p,g,w,m,d=this,v=d.c,y=(e=new _(e,r)).c;if(!(v&&y&&v[0]&&y[0]))return!d.s||!e.s||v&&!v[0]&&!y||y&&!y[0]&&!v?e.c=e.e=e.s=null:(e.s*=d.s,v&&y?(e.c=[0],e.e=0):e.c=e.e=null),e;for(t=j(d.e/M)+j(e.e/M),e.s*=d.s,(u=v.length)<(a=y.length)&&(g=v,v=y,y=g,i=u,u=a,a=i),i=u+a,g=[];i--;g.push(0));for(w=C,m=k,i=a;0<=--i;){for(n=0,h=y[i]%m,p=y[i]/m|0,o=i+(s=u);i<o;)n=((l=h*(l=v[--s]%m)+(f=p*l+(c=v[s]/m|0)*h)%m*m+g[o]+n)/w|0)+(f/m|0)+p*c,g[o--]=l%w;g[o]=n}return n?++t:g.splice(0,1),P(e,g,t)},t.negated=function(){var e=new _(this);return e.s=-e.s||null,e},t.plus=function(e,r){var n,t=this,i=t.s;if(r=(e=new _(e,r)).s,!i||!r)return new _(NaN);if(i!=r)return e.s=-r,t.minus(e);var o=t.e/M,s=e.e/M,f=t.c,u=e.c;if(!o||!s){if(!f||!u)return new _(i/0);if(!f[0]||!u[0])return u[0]?e:new _(f[0]?t:0*i)}if(o=j(o),s=j(s),f=f.slice(),i=o-s){for((n=0<i?(s=o,u):(i=-i,f)).reverse();i--;n.push(0));n.reverse()}for((i=f.length)-(r=u.length)<0&&(n=u,u=f,f=n,r=i),i=0;r;)i=(f[--r]=f[r]+u[r]+i)/C|0,f[r]=C===f[r]?0:f[r]%C;return i&&(f=[i].concat(f),++s),P(e,f,s)},t.precision=t.sd=function(e,r){var n,t,i;if(null!=e&&e!==!!e)return H(e,1,q),null==r?r=N:H(r,0,8),x(new _(this),e,r);if(!(n=this.c))return null;if(t=(i=n.length-1)*M+1,i=n[i]){for(;i%10==0;i/=10,t--);for(i=n[0];10<=i;i/=10,t++);}return e&&this.e+1>t&&(t=this.e+1),t},t.shiftedBy=function(e){return H(e,-G,G),this.times("1e"+e)},t.squareRoot=t.sqrt=function(){var e,r,n,t,i,o=this,s=o.c,f=o.s,u=o.e,l=y+4,c=new _("0.5");if(1!==f||!s||!s[0])return new _(!f||f<0&&(!s||s[0])?NaN:s?o:1/0);if((n=0==(f=Math.sqrt(+D(o)))||f==1/0?(((r=$(s)).length+u)%2==0&&(r+="0"),f=Math.sqrt(+r),u=j((u+1)/2)-(u<0||u%2),new _(r=f==1/0?"1e"+u:(r=f.toExponential()).slice(0,r.indexOf("e")+1)+u)):new _(f+"")).c[0])for((f=(u=n.e)+l)<3&&(f=0);;)if(i=n,n=c.times(i.plus(v(o,i,l,1))),$(i.c).slice(0,f)===(r=$(n.c)).slice(0,f)){if(n.e<u&&--f,"9999"!=(r=r.slice(f-3,f+1))&&(t||"4999"!=r)){+r&&(+r.slice(1)||"5"!=r.charAt(0))||(x(n,n.e+y+2,1),e=!n.times(n).eq(o));break}if(!t&&(x(i,i.e+y+2,0),i.times(i).eq(o))){n=i;break}l+=4,f+=4,t=1}return x(n,n.e+y+1,N,e)},t.toExponential=function(e,r){return null!=e&&(H(e,0,q),e++),S(this,e,r,1)},t.toFixed=function(e,r){return null!=e&&(H(e,0,q),e=e+this.e+1),S(this,e,r)},t.toFormat=function(e,r,n){var t;if(null==n)null!=e&&r&&"object"==typeof r?(n=r,r=null):e&&"object"==typeof e?(n=e,e=r=null):n=E;else if("object"!=typeof n)throw Error(U+"Argument not an object: "+n);if(t=this.toFixed(e,r),this.c){var i,o=t.split("."),s=+n.groupSize,f=+n.secondaryGroupSize,u=n.groupSeparator||"",l=o[0],c=o[1],a=this.s<0,h=a?l.slice(1):l,p=h.length;if(f&&(i=s,s=f,p-=f=i),0<s&&0<p){for(i=p%s||s,l=h.substr(0,i);i<p;i+=s)l+=u+h.substr(i,s);0<f&&(l+=u+h.slice(i)),a&&(l="-"+l)}t=c?l+(n.decimalSeparator||"")+((f=+n.fractionGroupSize)?c.replace(new RegExp("\\d{"+f+"}\\B","g"),"$&"+(n.fractionGroupSeparator||"")):c):l}return(n.prefix||"")+t+(n.suffix||"")},t.toFraction=function(e){var r,n,t,i,o,s,f,u,l,c,a,h,p=this,g=p.c;if(null!=e&&(!(f=new _(e)).isInteger()&&(f.c||1!==f.s)||f.lt(w)))throw Error(U+"Argument "+(f.isInteger()?"out of range: ":"not an integer: ")+D(f));if(!g)return new _(p);for(r=new _(w),l=n=new _(w),t=u=new _(w),h=$(g),o=r.e=h.length-p.e-1,r.c[0]=F[(s=o%M)<0?M+s:s],e=!e||0<f.comparedTo(r)?0<o?r:l:f,s=d,d=1/0,f=new _(h),u.c[0]=0;c=v(f,r,0,1),1!=(i=n.plus(c.times(t))).comparedTo(e);)n=t,t=i,l=u.plus(c.times(i=l)),u=i,r=f.minus(c.times(i=r)),f=i;return i=v(e.minus(n),t,0,1),u=u.plus(i.times(l)),n=n.plus(i.times(t)),u.s=l.s=p.s,a=v(l,t,o*=2,N).minus(p).abs().comparedTo(v(u,n,o,N).minus(p).abs())<1?[l,t]:[u,n],d=s,a},t.toNumber=function(){return+D(this)},t.toPrecision=function(e,r){return null!=e&&H(e,1,q),S(this,e,r,2)},t.toString=function(e){var r,n=this.s,t=this.e;return null===t?n?(r="Infinity",n<0&&(r="-"+r)):r="NaN":(r=$(this.c),r=null==e?t<=g||i<=t?W(r,t):X(r,t,"0"):(H(e,2,A.length,"Base"),a(X(r,t,"0"),10,e,n,!0)),n<0&&this.c[0]&&(r="-"+r)),r},t.valueOf=t.toJSON=function(){return D(this)},t._isBigNumber=!0,"function"==typeof Symbol&&"symbol"==typeof Symbol.iterator&&(t[Symbol.toStringTag]="BigNumber",t[Symbol.for("nodejs.util.inspect.custom")]=t.valueOf),null!=r&&_.set(r),_}()).default=r.BigNumber=r,"function"==typeof define&&define.amd?define(function(){return r}):"undefined"!=typeof module&&module.exports?module.exports=r:(e||(e="undefined"!=typeof self&&self?self:window),e.BigNumber=r)}(this);

const BN = module.exports.BigNumber;

let l = 0;
rl.on('line', (input) => {
    if (l == 0) { l++ }
    else {
        rl.close();
        let strArray = input.split(" ")
        let s = strArray.map(function (item) {
            return BN(item);
        });
        let res = []
        let n = s.length * 2
        res[0] = BN(0)
        res[n - 1] = s[0]
        for (let i = 1; i < s.length; i++) {
            if (s[i] - res[i - 1] > res[n - (i - 1) - 1]) {

                res[i] = s[i] - (res[n - (i - 1) - 1])
                if (res[i - 1] > res[i]) {
                    res[i] -= res[i - 1]
                }
                res[n - i - 1] = s[i] - res[i]

            } else {
                res[i] = res[i - 1]
                res[n - i - 1] = s[i] - res[i - 1]
            }
        }
        console.log(res.join(" "))
        return 0;
    }
});

//4 5 4 4 3 4
//0 1 1 1 1 2 2 2 3 3 4 4
//0 1 1 1 1     2 3 3 4 4
//0 1 1 1 1 1 3 2 3 3 4 4

const readline = require('readline');
const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
});

let l = 0;
rl.on('line', (input) => {
    if (l == 0) { l++ }
    else {
        rl.close();
        let strArray = input.split(" ")
        let s = strArray.map(function (item) {
            return parseInt(item, 10);
        });
        let res = []
        let n = s.length * 2
        res[0] = 0
        res[n - 1] = s[0]
        for (let i = 1; i < s.length; i++) {
            if (s[i] - res[i - 1] > res[n - (i - 1)-1]) {
                res[i] = s[i] - res[i - 1] - res[n - (i - 1)-1]
                res[n-i - 1] = s[i] - res[i]

            } else {
                res[i] = res[i - 1]
                res[n - i - 1] = s[i]-res[i-1]
            }
        }
        console.log(res)
        return 0;
    }
});

const readline = require('readline');
const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
});

let l = 0;
rl.on('line', (input) => {
    if (l == 0) { l++ }
    else {
        rl.close();
        let strArray = input.split(" ")
        let s = strArray.map(function (item) {
            return parseInt(item, 10);
        });
        let res = []
        let n = s.length * 2
        res[0] = 0
        res[n - 1] = s[0]
        for (let i = 1; i < s.length; i++) {
            if (s[i] - res[i - 1] > res[n - (i - 1) - 1]) {

                res[i] = s[i] - (res[n - (i - 1) - 1])
                if (res[i - 1] > res[i]) {
                    res[i] -= res[i - 1]
                }
                res[n - i - 1] = s[i] - res[i]

            } else {
                res[i] = res[i - 1]
                res[n - i - 1] = s[i] - res[i - 1]
            }
        }
        console.log(res.join(" "))
        return 0;
    }
});

//4 5 4 4 3 4
//0 1 1 1 1 2 2 2 3 3 4 4
//0 1 1 1 1     2 3 3 4 4
//0 1 1 1 1 1 3 2 3 3 4 4

const readline = require('readline');
const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
});
!function(e){"use strict";var r,L=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,B=Math.ceil,T=Math.floor,U="[BigNumber Error] ",I=U+"Number primitive has more than 15 significant digits: ",C=1e14,M=14,G=9007199254740991,F=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],k=1e7,q=1e9;function j(e){var r=0|e;return 0<e||e===r?r:r-1}function $(e){for(var r,n,t=1,i=e.length,o=e[0]+"";t<i;){for(r=e[t++]+"",n=M-r.length;n--;r="0"+r);o+=r}for(i=o.length;48===o.charCodeAt(--i););return o.slice(0,i+1||1)}function z(e,r){var n,t,i=e.c,o=r.c,s=e.s,f=r.s,u=e.e,l=r.e;if(!s||!f)return null;if(n=i&&!i[0],t=o&&!o[0],n||t)return n?t?0:-f:s;if(s!=f)return s;if(n=s<0,t=u==l,!i||!o)return t?0:!i^n?1:-1;if(!t)return l<u^n?1:-1;for(f=(u=i.length)<(l=o.length)?u:l,s=0;s<f;s++)if(i[s]!=o[s])return i[s]>o[s]^n?1:-1;return u==l?0:l<u^n?1:-1}function H(e,r,n,t){if(e<r||n<e||e!==(e<0?B(e):T(e)))throw Error(U+(t||"Argument")+("number"==typeof e?e<r||n<e?" out of range: ":" not an integer: ":" not a primitive number: ")+String(e))}function V(e){var r=e.c.length-1;return j(e.e/M)==r&&e.c[r]%2!=0}function W(e,r){return(1<e.length?e.charAt(0)+"."+e.slice(1):e)+(r<0?"e":"e+")+r}function X(e,r,n){var t,i;if(r<0){for(i=n+".";++r;i+=n);e=i+e}else if(++r>(t=e.length)){for(i=n,r-=t;--r;i+=n);e+=i}else r<t&&(e=e.slice(0,r)+"."+e.slice(r));return e}(r=function e(r){var v,a,h,n,l,s,f,u,c,p,t=_.prototype={constructor:_,toString:null,valueOf:null},w=new _(1),y=20,N=4,g=-7,i=21,m=-1e7,d=1e7,O=!1,o=1,b=0,E={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:" ",suffix:""},A="0123456789abcdefghijklmnopqrstuvwxyz";function _(e,r){var n,t,i,o,s,f,u,l,c=this;if(!(c instanceof _))return new _(e,r);if(null==r){if(e instanceof _)return c.s=e.s,c.e=e.e,void(c.c=(e=e.c)?e.slice():e);if((f="number"==typeof e)&&0*e==0){if(c.s=1/e<0?(e=-e,-1):1,e===~~e){for(o=0,s=e;10<=s;s/=10,o++);return c.e=o,void(c.c=[e])}l=String(e)}else{if(l=String(e),!L.test(l))return h(c,l,f);c.s=45==l.charCodeAt(0)?(l=l.slice(1),-1):1}-1<(o=l.indexOf("."))&&(l=l.replace(".","")),0<(s=l.search(/e/i))?(o<0&&(o=s),o+=+l.slice(s+1),l=l.substring(0,s)):o<0&&(o=l.length)}else{if(H(r,2,A.length,"Base"),l=String(e),10==r)return x(c=new _(e instanceof _?e:l),y+c.e+1,N);if(f="number"==typeof e){if(0*e!=0)return h(c,l,f,r);if(c.s=1/e<0?(l=l.slice(1),-1):1,_.DEBUG&&15<l.replace(/^0\.0*|\./,"").length)throw Error(I+e);f=!1}else c.s=45===l.charCodeAt(0)?(l=l.slice(1),-1):1;for(n=A.slice(0,r),o=s=0,u=l.length;s<u;s++)if(n.indexOf(t=l.charAt(s))<0){if("."==t){if(o<s){o=u;continue}}else if(!i&&(l==l.toUpperCase()&&(l=l.toLowerCase())||l==l.toLowerCase()&&(l=l.toUpperCase()))){i=!0,s=-1,o=0;continue}return h(c,String(e),f,r)}-1<(o=(l=a(l,r,10,c.s)).indexOf("."))?l=l.replace(".",""):o=l.length}for(s=0;48===l.charCodeAt(s);s++);for(u=l.length;48===l.charCodeAt(--u););if(l=l.slice(s,++u)){if(u-=s,f&&_.DEBUG&&15<u&&(G<e||e!==T(e)))throw Error(I+c.s*e);if(d<(o=o-s-1))c.c=c.e=null;else if(o<m)c.c=[c.e=0];else{if(c.e=o,c.c=[],s=(o+1)%M,o<0&&(s+=M),s<u){for(s&&c.c.push(+l.slice(0,s)),u-=M;s<u;)c.c.push(+l.slice(s,s+=M));l=l.slice(s),s=M-l.length}else s-=u;for(;s--;l+="0");c.c.push(+l)}}else c.c=[c.e=0]}function S(e,r,n,t){var i,o,s,f,u;if(null==n?n=N:H(n,0,8),!e.c)return e.toString();if(i=e.c[0],s=e.e,null==r)u=$(e.c),u=1==t||2==t&&s<=g?W(u,s):X(u,s,"0");else if(o=(e=x(new _(e),r,n)).e,f=(u=$(e.c)).length,1==t||2==t&&(r<=o||o<=g)){for(;f<r;u+="0",f++);u=W(u,o)}else if(r-=s,u=X(u,o,"0"),f<o+1){if(0<--r)for(u+=".";r--;u+="0");}else if(0<(r+=o-f))for(o+1==f&&(u+=".");r--;u+="0");return e.s<0&&i?"-"+u:u}function R(e,r){for(var n,t=1,i=new _(e[0]);t<e.length;t++){if(!(n=new _(e[t])).s){i=n;break}r.call(i,n)&&(i=n)}return i}function P(e,r,n){for(var t=1,i=r.length;!r[--i];r.pop());for(i=r[0];10<=i;i/=10,t++);return(n=t+n*M-1)>d?e.c=e.e=null:e.c=n<m?[e.e=0]:(e.e=n,r),e}function x(e,r,n,t){var i,o,s,f,u,l,c,a=e.c,h=F;if(a){e:{for(i=1,f=a[0];10<=f;f/=10,i++);if((o=r-i)<0)o+=M,s=r,c=(u=a[l=0])/h[i-s-1]%10|0;else if((l=B((o+1)/M))>=a.length){if(!t)break e;for(;a.length<=l;a.push(0));u=c=0,s=(o%=M)-M+(i=1)}else{for(u=f=a[l],i=1;10<=f;f/=10,i++);c=(s=(o%=M)-M+i)<0?0:u/h[i-s-1]%10|0}if(t=t||r<0||null!=a[l+1]||(s<0?u:u%h[i-s-1]),t=n<4?(c||t)&&(0==n||n==(e.s<0?3:2)):5<c||5==c&&(4==n||t||6==n&&(0<o?0<s?u/h[i-s]:0:a[l-1])%10&1||n==(e.s<0?8:7)),r<1||!a[0])return a.length=0,t?(r-=e.e+1,a[0]=h[(M-r%M)%M],e.e=-r||0):a[0]=e.e=0,e;if(0==o?(a.length=l,f=1,l--):(a.length=l+1,f=h[M-o],a[l]=0<s?T(u/h[i-s]%h[s])*f:0),t)for(;;){if(0==l){for(o=1,s=a[0];10<=s;s/=10,o++);for(s=a[0]+=f,f=1;10<=s;s/=10,f++);o!=f&&(e.e++,a[0]==C&&(a[0]=1));break} if(a[l]+=f,a[l]!=C)break;a[l--]=0,f=1}for(o=a.length;0===a[--o];a.pop());}e.e>d?e.c=e.e=null:e.e<m&&(e.c=[e.e=0])}return e}function D(e){var r,n=e.e;return null===n?e.toString():(r=$(e.c),r=n<=g||i<=n?W(r,n):X(r,n,"0"),e.s<0?"-"+r:r)}return _.clone=e,_.ROUND_UP=0,_.ROUND_DOWN=1,_.ROUND_CEIL=2,_.ROUND_FLOOR=3,_.ROUND_HALF_UP=4,_.ROUND_HALF_DOWN=5,_.ROUND_HALF_EVEN=6,_.ROUND_HALF_CEIL=7,_.ROUND_HALF_FLOOR=8,_.EUCLID=9,_.config=_.set=function(e){var r,n;if(null!=e){if("object"!=typeof e)throw Error(U+"Object expected: "+e);if(e.hasOwnProperty(r="DECIMAL_PLACES")&&(H(n=e[r],0,q,r),y=n),e.hasOwnProperty(r="ROUNDING_MODE")&&(H(n=e[r],0,8,r),N=n),e.hasOwnProperty(r="EXPONENTIAL_AT")&&((n=e[r])&&n.pop?(H(n[0],-q,0,r),H(n[1],0,q,r),g=n[0],i=n[1]):(H(n,-q,q,r),g=-(i=n<0?-n:n))),e.hasOwnProperty(r="RANGE"))if((n=e[r])&&n.pop)H(n[0],-q,-1,r),H(n[1],1,q,r),m=n[0],d=n[1];else{if(H(n,-q,q,r),!n)throw Error(U+r+" cannot be zero: "+n);m=-(d=n<0?-n:n)}if(e.hasOwnProperty(r="CRYPTO")){if((n=e[r])!==!!n)throw Error(U+r+" not true or false: "+n);if(n){if("undefined"==typeof crypto||!crypto||!crypto.getRandomValues&&!crypto.randomBytes)throw O=!n,Error(U+"crypto unavailable");O=n}else O=n}if(e.hasOwnProperty(r="MODULO_MODE")&&(H(n=e[r],0,9,r),o=n),e.hasOwnProperty(r="POW_PRECISION")&&(H(n=e[r],0,q,r),b=n),e.hasOwnProperty(r="FORMAT")){if("object"!=typeof(n=e[r]))throw Error(U+r+" not an object: "+n);E=n}if(e.hasOwnProperty(r="ALPHABET")){if("string"!=typeof(n=e[r])||/^.$|[+-.\s]|(.).*\1/.test(n))throw Error(U+r+" invalid: "+n);A=n}}return{DECIMAL_PLACES:y,ROUNDING_MODE:N,EXPONENTIAL_AT:[g,i],RANGE:[m,d],CRYPTO:O,MODULO_MODE:o,POW_PRECISION:b,FORMAT:E,ALPHABET:A}},_.isBigNumber=function(e){return e instanceof _||e&&!0===e._isBigNumber||!1},_.maximum=_.max=function(){return R(arguments,t.lt)},_.minimum=_.min=function(){return R(arguments,t.gt)},_.random=(n=9007199254740992,l=Math.random()*n&2097151?function(){return T(Math.random()*n)}:function(){return 8388608*(1073741824*Math.random()|0)+(8388608*Math.random()|0)},function(e){var r,n,t,i,o,s=0,f=[],u=new _(w);if(null==e?e=y:H(e,0,q),i=B(e/M),O)if(crypto.getRandomValues){for(r=crypto.getRandomValues(new Uint32Array(i*=2));s<i;)9e15<=(o=131072*r[s]+(r[s+1]>>>11))?(n=crypto.getRandomValues(new Uint32Array(2)),r[s]=n[0],r[s+1]=n[1]):(f.push(o%1e14),s+=2);s=i/2}else{if(!crypto.randomBytes)throw O=!1,Error(U+"crypto unavailable");for(r=crypto.randomBytes(i*=7);s<i;)9e15<=(o=281474976710656*(31&r[s])+1099511627776*r[s+1]+4294967296*r[s+2]+16777216*r[s+3]+(r[s+4]<<16)+(r[s+5]<<8)+r[s+6])?crypto.randomBytes(7).copy(r,s):(f.push(o%1e14),s+=7);s=i/7}if(!O)for(;s<i;) (o=l())<9e15&&(f[s++]=o%1e14);for(i=f[--s],e%=M,i&&e&&(o=F[M-e],f[s]=T(i/o)*o);0===f[s];f.pop(),s--);if(s<0)f=[t=0];else{for(t=-1;0===f[0];f.splice(0,1),t-=M);for(s=1,o=f[0];10<=o;o/=10,s++);s<M&&(t-=M-s)}return u.e=t,u.c=f,u}),_.sum=function(){for(var e=1,r=arguments,n=new _(r[0]);e<r.length;)n=n.plus(r[e++]);return n},a=function(){var m="0123456789";function d(e,r,n,t){for(var i,o,s=[0],f=0,u=e.length;f<u;){for(o=s.length;o--;s[o]*=r);for(s[0]+=t.indexOf(e.charAt(f++)),i=0;i<s.length;i++)s[i]>n-1&&(null==s[i+1]&&(s[i+1]=0),s[i+1]+=s[i]/n|0,s[i]%=n)}return s.reverse()}return function(e,r,n,t,i){var o,s,f,u,l,c,a,h,p=e.indexOf("."),g=y,w=N;for(0<=p&&(u=b,b=0,e=e.replace(".",""),c=(h=new _(r)).pow(e.length-p),b=u,h.c=d(X($(c.c),c.e,"0"),10,n,m),h.e=h.c.length),f=u=(a=d(e,r,n,i?(o=A,m):(o=m,A))).length;0==a[--u];a.pop());if(!a[0])return o.charAt(0);if(p<0?--f:(c.c=a,c.e=f,c.s=t,a=(c=v(c,h,g,w,n)).c,l=c.r,f=c.e),p=a[s=f+g+1],u=n/2,l=l||s<0||null!=a[s+1],l=w<4?(null!=p||l)&&(0==w||w==(c.s<0?3:2)):u<p||p==u&&(4==w||l||6==w&&1&a[s-1]||w==(c.s<0?8:7)),s<1||!a[0])e=l?X(o.charAt(1),-g,o.charAt(0)):o.charAt(0);else{if(a.length=s,l)for(--n;++a[--s]>n;)a[s]=0,s||(++f,a=[1].concat(a));for(u=a.length;!a[--u];);for(p=0,e="";p<=u;e+=o.charAt(a[p++]));e=X(e,f,o.charAt(0))}return e}}(),v=function(){function S(e,r,n){var t,i,o,s,f=0,u=e.length,l=r%k,c=r/k|0;for(e=e.slice();u--;)f=((i=l*(o=e[u]%k)+(t=c*o+(s=e[u]/k|0)*l)%k*k+f)/n|0)+(t/k|0)+c*s,e[u]=i%n;return f&&(e=[f].concat(e)),e}function R(e,r,n,t){var i,o;if(n!=t)o=t<n?1:-1;else for(i=o=0;i<n;i++)if(e[i]!=r[i]){o=e[i]>r[i]?1:-1;break}return o}function P(e,r,n,t){for(var i=0;n--;)e[n]-=i,i=e[n]<r[n]?1:0,e[n]=i*t+e[n]-r[n];for(;!e[0]&&1<e.length;e.splice(0,1));}return function(e,r,n,t,i){var o,s,f,u,l,c,a,h,p,g,w,m,d,v,y,N,O,b=e.s==r.s?1:-1,E=e.c,A=r.c;if(!(E&&E[0]&&A&&A[0]))return new _(e.s&&r.s&&(E?!A||E[0]!=A[0]:A)?E&&0==E[0]||!A?0*b:b/0:NaN);for(p=(h=new _(b)).c=[],b=n+(s=e.e-r.e)+1,i||(i=C,s=j(e.e/M)-j(r.e/M),b=b/M|0),f=0;A[f]==(E[f]||0);f++);if(A[f]>(E[f]||0)&&s--,b<0)p.push(1),u=!0;else{for(v=E.length,N=A.length,b+=2,1<(l=T(i/(A[f=0]+1)))&&(A=S(A,l,i),E=S(E,l,i),N=A.length,v=E.length),d=N,w=(g=E.slice(0,N)).length;w<N;g[w++]=0);O=A.slice(),O=[0].concat(O),y=A[0],A[1]>=i/2&&y++;do{if(l=0,(o=R(A,g,N,w))<0){if(m=g[0],N!=w&&(m=m*i+(g[1]||0)),1<(l=T(m/y)))for(i<=l&&(l=i-1),a=(c=S(A,l,i)).length,w=g.length;1==R(c,g,a,w);)l--,P(c,N<a?O:A,a,i),a=c.length,o=1;else 0==l&&(o=l=1),a=(c=A.slice()).length;if(a<w&&(c=[0].concat(c)),P(g,c,w,i),w=g.length,-1==o)for(;R(A,g,N,w)<1;)l++,P(g,N<w?O:A,w,i),w=g.length}else 0===o&&(l++,g=[0]);p[f++]=l,g[0]?g[w++]=E[d]||0:(g=[E[d]],w=1)}while((d++<v||null!=g[0])&&b--);u=null!=g[0],p[0]||p.splice(0,1)}if(i==C){for(f=1,b=p[0];10<=b;b/=10,f++);x(h,n+(h.e=f+s*M-1)+1,t,u)}else h.e=s,h.r=+u;return h}}(),s=/^(-?)0([xbo])(?=\w[\w.]*$)/i,f=/^([^.]+)\.$/,u=/^\.([^.]+)$/,c=/^-?(Infinity|NaN)$/,p=/^\s*\+(?=[\w.])|^\s+|\s+$/g,h=function(e,r,n,t){var i,o=n?r:r.replace(p,"");if(c.test(o))e.s=isNaN(o)?null:o<0?-1:1,e.c=e.e=null;else{if(!n&&(o=o.replace(s,function(e,r,n){return i="x"==(n=n.toLowerCase())?16:"b"==n?2:8,t&&t!=i?e:r}),t&&(i=t,o=o.replace(f,"$1").replace(u,"0.$1")),r!=o))return new _(o,i);if(_.DEBUG)throw Error(U+"Not a"+(t?" base "+t:"")+" number: "+r);e.c=e.e=e.s=null}},t.absoluteValue=t.abs=function(){var e=new _(this);return e.s<0&&(e.s=1),e},t.comparedTo=function(e,r){return z(this,new _(e,r))},t.decimalPlaces=t.dp=function(e,r){var n,t,i;if(null!=e)return H(e,0,q),null==r?r=N:H(r,0,8),x(new _(this),e+this.e+1,r);if(!(n=this.c))return null;if(t=((i=n.length-1)-j(this.e/M))*M,i=n[i])for(;i%10==0;i/=10,t--);return t<0&&(t=0),t},t.dividedBy=t.div=function(e,r){return v(this,new _(e,r),y,N)},t.dividedToIntegerBy=t.idiv=function(e,r){return v(this,new _(e,r),0,1)},t.exponentiatedBy=t.pow=function(e,r){var n,t,i,o,s,f,u,l,c=this;if((e=new _(e)).c&&!e.isInteger())throw Error(U+"Exponent not an integer: "+D(e));if(null!=r&&(r=new _(r)),s=14<e.e,!c.c||!c.c[0]||1==c.c[0]&&!c.e&&1==c.c.length||!e.c||!e.c[0])return l=new _(Math.pow(+D(c),s?2-V(e):+D(e))),r?l.mod(r):l;if(f=e.s<0,r){if(r.c?!r.c[0]:!r.s)return new _(NaN);(t=!f&&c.isInteger()&&r.isInteger())&&(c=c.mod(r))}else{if(9<e.e&&(0<c.e||c.e<-1||(0==c.e?1<c.c[0]||s&&24e7<=c.c[1]:c.c[0]<8e13||s&&c.c[0]<=9999975e7)))return o=c.s<0&&V(e)?-0:0,-1<c.e&&(o=1/o),new _(f?1/o:o);b&&(o=B(b/M+2))}for(u=s?(n=new _(.5),f&&(e.s=1),V(e)):(i=Math.abs(+D(e)))%2,l=new _(w);;){if(u){if(!(l=l.times(c)).c)break;o?l.c.length>o&&(l.c.length=o):t&&(l=l.mod(r))}if(i){if(0===(i=T(i/2)))break;u=i%2}else if(x(e=e.times(n),e.e+1,1),14<e.e)u=V(e);else{if(0==(i=+D(e)))break;u=i%2}c=c.times(c),o?c.c&&c.c.length>o&&(c.c.length=o):t&&(c=c.mod(r))}return t?l:(f&&(l=w.div(l)),r?l.mod(r):o?x(l,b,N,void 0):l)},t.integerValue=function(e){var r=new _(this);return null==e?e=N:H(e,0,8),x(r,r.e+1,e)},t.isEqualTo=t.eq=function(e,r){return 0===z(this,new _(e,r))},t.isFinite=function(){return!!this.c},t.isGreaterThan=t.gt=function(e,r){return 0<z(this,new _(e,r))},t.isGreaterThanOrEqualTo=t.gte=function(e,r){return 1===(r=z(this,new _(e,r)))||0===r},t.isInteger=function(){return!!this.c&&j(this.e/M)>this.c.length-2},t.isLessThan=t.lt=function(e,r){return z(this,new _(e,r))<0},t.isLessThanOrEqualTo=t.lte=function(e,r){return-1===(r=z(this,new _(e,r)))||0===r},t.isNaN=function(){return!this.s},t.isNegative=function(){return this.s<0},t.isPositive=function(){return 0<this.s},t.isZero=function(){return!!this.c&&0==this.c[0]},t.minus=function(e,r){var n,t,i,o,s=this,f=s.s;if(r=(e=new _(e,r)).s,!f||!r)return new _(NaN);if(f!=r)return e.s=-r,s.plus(e);var u=s.e/M,l=e.e/M,c=s.c,a=e.c;if(!u||!l){if(!c||!a)return c?(e.s=-r,e):new _(a?s:NaN);if(!c[0]||!a[0])return a[0]?(e.s=-r,e):new _(c[0]?s:3==N?-0:0)}if(u=j(u),l=j(l),c=c.slice(),f=u-l){for((i=(o=f<0)?(f=-f,c):(l=u,a)).reverse(),r=f;r--;i.push(0));i.reverse()}else for(t=(o=(f=c.length)<(r=a.length))?f:r,f=r=0;r<t;r++)if(c[r]!=a[r]){o=c[r]<a[r];break}if(o&&(i=c,c=a,a=i,e.s=-e.s),0<(r=(t=a.length)-(n=c.length)))for(;r--;c[n++]=0);for(r=C-1;f<t;){if(c[--t]<a[t]){for(n=t;n&&!c[--n];c[n]=r);--c[n],c[t]+=C}c[t]-=a[t]}for(;0==c[0];c.splice(0,1),--l);return c[0]?P(e,c,l):(e.s=3==N?-1:1,e.c=[e.e=0],e)},t.modulo=t.mod=function(e,r){var n,t,i=this;return e=new _(e,r),!i.c||!e.s||e.c&&!e.c[0]?new _(NaN):!e.c||i.c&&!i.c[0]?new _(i):(9==o?(t=e.s,e.s=1,n=v(i,e,0,3),e.s=t,n.s*=t):n=v(i,e,0,o),(e=i.minus(n.times(e))).c[0]||1!=o||(e.s=i.s),e)},t.multipliedBy=t.times=function(e,r){var n,t,i,o,s,f,u,l,c,a,h,p,g,w,m,d=this,v=d.c,y=(e=new _(e,r)).c;if(!(v&&y&&v[0]&&y[0]))return!d.s||!e.s||v&&!v[0]&&!y||y&&!y[0]&&!v?e.c=e.e=e.s=null:(e.s*=d.s,v&&y?(e.c=[0],e.e=0):e.c=e.e=null),e;for(t=j(d.e/M)+j(e.e/M),e.s*=d.s,(u=v.length)<(a=y.length)&&(g=v,v=y,y=g,i=u,u=a,a=i),i=u+a,g=[];i--;g.push(0));for(w=C,m=k,i=a;0<=--i;){for(n=0,h=y[i]%m,p=y[i]/m|0,o=i+(s=u);i<o;)n=((l=h*(l=v[--s]%m)+(f=p*l+(c=v[s]/m|0)*h)%m*m+g[o]+n)/w|0)+(f/m|0)+p*c,g[o--]=l%w;g[o]=n}return n?++t:g.splice(0,1),P(e,g,t)},t.negated=function(){var e=new _(this);return e.s=-e.s||null,e},t.plus=function(e,r){var n,t=this,i=t.s;if(r=(e=new _(e,r)).s,!i||!r)return new _(NaN);if(i!=r)return e.s=-r,t.minus(e);var o=t.e/M,s=e.e/M,f=t.c,u=e.c;if(!o||!s){if(!f||!u)return new _(i/0);if(!f[0]||!u[0])return u[0]?e:new _(f[0]?t:0*i)}if(o=j(o),s=j(s),f=f.slice(),i=o-s){for((n=0<i?(s=o,u):(i=-i,f)).reverse();i--;n.push(0));n.reverse()}for((i=f.length)-(r=u.length)<0&&(n=u,u=f,f=n,r=i),i=0;r;)i=(f[--r]=f[r]+u[r]+i)/C|0,f[r]=C===f[r]?0:f[r]%C;return i&&(f=[i].concat(f),++s),P(e,f,s)},t.precision=t.sd=function(e,r){var n,t,i;if(null!=e&&e!==!!e)return H(e,1,q),null==r?r=N:H(r,0,8),x(new _(this),e,r);if(!(n=this.c))return null;if(t=(i=n.length-1)*M+1,i=n[i]){for(;i%10==0;i/=10,t--);for(i=n[0];10<=i;i/=10,t++);}return e&&this.e+1>t&&(t=this.e+1),t},t.shiftedBy=function(e){return H(e,-G,G),this.times("1e"+e)},t.squareRoot=t.sqrt=function(){var e,r,n,t,i,o=this,s=o.c,f=o.s,u=o.e,l=y+4,c=new _("0.5");if(1!==f||!s||!s[0])return new _(!f||f<0&&(!s||s[0])?NaN:s?o:1/0);if((n=0==(f=Math.sqrt(+D(o)))||f==1/0?(((r=$(s)).length+u)%2==0&&(r+="0"),f=Math.sqrt(+r),u=j((u+1)/2)-(u<0||u%2),new _(r=f==1/0?"1e"+u:(r=f.toExponential()).slice(0,r.indexOf("e")+1)+u)):new _(f+"")).c[0])for((f=(u=n.e)+l)<3&&(f=0);;)if(i=n,n=c.times(i.plus(v(o,i,l,1))),$(i.c).slice(0,f)===(r=$(n.c)).slice(0,f)){if(n.e<u&&--f,"9999"!=(r=r.slice(f-3,f+1))&&(t||"4999"!=r)){+r&&(+r.slice(1)||"5"!=r.charAt(0))||(x(n,n.e+y+2,1),e=!n.times(n).eq(o));break}if(!t&&(x(i,i.e+y+2,0),i.times(i).eq(o))){n=i;break}l+=4,f+=4,t=1}return x(n,n.e+y+1,N,e)},t.toExponential=function(e,r){return null!=e&&(H(e,0,q),e++),S(this,e,r,1)},t.toFixed=function(e,r){return null!=e&&(H(e,0,q),e=e+this.e+1),S(this,e,r)},t.toFormat=function(e,r,n){var t;if(null==n)null!=e&&r&&"object"==typeof r?(n=r,r=null):e&&"object"==typeof e?(n=e,e=r=null):n=E;else if("object"!=typeof n)throw Error(U+"Argument not an object: "+n);if(t=this.toFixed(e,r),this.c){var i,o=t.split("."),s=+n.groupSize,f=+n.secondaryGroupSize,u=n.groupSeparator||"",l=o[0],c=o[1],a=this.s<0,h=a?l.slice(1):l,p=h.length;if(f&&(i=s,s=f,p-=f=i),0<s&&0<p){for(i=p%s||s,l=h.substr(0,i);i<p;i+=s)l+=u+h.substr(i,s);0<f&&(l+=u+h.slice(i)),a&&(l="-"+l)}t=c?l+(n.decimalSeparator||"")+((f=+n.fractionGroupSize)?c.replace(new RegExp("\\d{"+f+"}\\B","g"),"$&"+(n.fractionGroupSeparator||"")):c):l}return(n.prefix||"")+t+(n.suffix||"")},t.toFraction=function(e){var r,n,t,i,o,s,f,u,l,c,a,h,p=this,g=p.c;if(null!=e&&(!(f=new _(e)).isInteger()&&(f.c||1!==f.s)||f.lt(w)))throw Error(U+"Argument "+(f.isInteger()?"out of range: ":"not an integer: ")+D(f));if(!g)return new _(p);for(r=new _(w),l=n=new _(w),t=u=new _(w),h=$(g),o=r.e=h.length-p.e-1,r.c[0]=F[(s=o%M)<0?M+s:s],e=!e||0<f.comparedTo(r)?0<o?r:l:f,s=d,d=1/0,f=new _(h),u.c[0]=0;c=v(f,r,0,1),1!=(i=n.plus(c.times(t))).comparedTo(e);)n=t,t=i,l=u.plus(c.times(i=l)),u=i,r=f.minus(c.times(i=r)),f=i;return i=v(e.minus(n),t,0,1),u=u.plus(i.times(l)),n=n.plus(i.times(t)),u.s=l.s=p.s,a=v(l,t,o*=2,N).minus(p).abs().comparedTo(v(u,n,o,N).minus(p).abs())<1?[l,t]:[u,n],d=s,a},t.toNumber=function(){return+D(this)},t.toPrecision=function(e,r){return null!=e&&H(e,1,q),S(this,e,r,2)},t.toString=function(e){var r,n=this.s,t=this.e;return null===t?n?(r="Infinity",n<0&&(r="-"+r)):r="NaN":(r=$(this.c),r=null==e?t<=g||i<=t?W(r,t):X(r,t,"0"):(H(e,2,A.length,"Base"),a(X(r,t,"0"),10,e,n,!0)),n<0&&this.c[0]&&(r="-"+r)),r},t.valueOf=t.toJSON=function(){return D(this)},t._isBigNumber=!0,"function"==typeof Symbol&&"symbol"==typeof Symbol.iterator&&(t[Symbol.toStringTag]="BigNumber",t[Symbol.for("nodejs.util.inspect.custom")]=t.valueOf),null!=r&&_.set(r),_}()).default=r.BigNumber=r,"function"==typeof define&&define.amd?define(function(){return r}):"undefined"!=typeof module&&module.exports?module.exports=r:(e||(e="undefined"!=typeof self&&self?self:window),e.BigNumber=r)}(this);

const BN = module.exports.BigNumber;

let l = 0;
rl.on('line', (input) => {
    if (l == 0) { l++ }
    else {
        rl.close();
        let strArray = input.split(" ")
        let s = strArray.map(function (item) {
            return BN(item);
        });
        let res = []
        let n = s.length * 2
        res[0] = BN(0)
        res[n - 1] = s[0]
        for (let i = 1; i < s.length; i++) {
            if (s[i].minus(res[i - 1]) > res[n - (i - 1) - 1]) {

                res[i] = s[i].minus(res[n - (i - 1) - 1])
                if (res[i - 1] > res[i]) {
                    res[i] =res[i].minus(res[i - 1])
                }
                res[n - i - 1] = s[i].minus(res[i])

            } else {
                res[i] = res[i - 1]
                res[n - i - 1] = s[i].minus(res[i - 1])
            }
        }
        console.log(res.join(" "))
        return 0;
    }
});

//4 5 4 4 3 4
//0 1 1 1 1 2 2 2 3 3 4 4
//0 1 1 1 1     2 3 3 4 4
//0 1 1 1 1 1 3 2 3 3 4 4

const readline = require('readline');
const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
});

let l = 0;
rl.on('line', (input) => {
    if (l == 0) { l++ }
    else {
        rl.close();
        let strArray = input.split(" ")
        let s = strArray.map(function (item) {
            return parseInt(item, 10);
        });
        let res = []
        let n = s.length * 2
        res[0] = 0
        res[n - 1] = s[0]
        for (let i = 1; i < s.length; i++) {
            if (s[i] - res[i - 1] > res[n - (i - 1)-1]) {
                res[i] = s[i] - res[i - 1] - res[n - (i - 1)-1]
                res[n-i - 1] = s[i] - res[i]

            } else {
                res[i] = res[i - 1]
                res[n - i - 1] = s[i]-res[i-1]
            }
        }
        console.log(res.join(" "))
        return 0;
    }
});

function main() {

    var n = stdin[0];
    n = parseInt(n);

    var b = stdin[1].split(' ').map( (s) => { return new Int64(s); });
    var a = [];
    a[0] = 0;
    a[n-1] = b[0];

    for(var i=1 ; i<n/2 ; i++) {
        if( b[i] < b[i-1] ) {
            a[i] = a[i-1];
            a[n-i-1] = b[i] - a[i];
        } else {
            a[n-i-1] = a[n-i];
            a[i] = b[i] - a[n-i-1];
        }
    }

    for(var i=0 ; i<n ; i++) {
        process.stdout.write(a[i] + " ");
    }
    //console.log(a);

}

const readline = require('readline');
const rl = readline.createInterface(process.stdin, process.stdout, null);

var stdin = [];
rl.on('line', function (line) {stdin.push(line);});
rl.on('close', main);

//     Int64.js
//
//     Copyright (c) 2012 Robert Kieffer
//     MIT License - http://opensource.org/licenses/mit-license.php

/**
 * Support for handling 64-bit int numbers in Javascript (node.js)
 *
 * JS Numbers are IEEE-754 binary double-precision floats, which limits the
 * range of values that can be represented with integer precision to:
 *
 * 2^^53 <= N <= 2^53
 *
 * Int64 objects wrap a node Buffer that holds the 8-bytes of int64 data.  These
 * objects operate directly on the buffer which means that if they are created
 * using an existing buffer then setting the value will modify the Buffer, and
 * vice-versa.
 *
 * Internal Representation
 *
 * The internal buffer format is Big Endian.  I.e. the most-significant byte is
 * at buffer[0], the least-significant at buffer[7].  For the purposes of
 * converting to/from JS native numbers, the value is assumed to be a signed
 * integer stored in 2's complement form.
 *
 * For details about IEEE-754 see:
 * http://en.wikipedia.org/wiki/Double_precision_floating-point_format
 */

// Useful masks and values for bit twiddling
var MASK31 =  0x7fffffff, VAL31 = 0x80000000;
var MASK32 =  0xffffffff, VAL32 = 0x100000000;

// Map for converting hex octets to strings
var _HEX = [];
for (var i = 0; i < 256; i++) {
  _HEX[i] = (i > 0xF ? '' : '0') + i.toString(16);
}

//
// Int64
//

/**
 * Constructor accepts any of the following argument types:
 *
 * new Int64(buffer[, offset=0]) - Existing Buffer with byte offset
 * new Int64(Uint8Array[, offset=0]) - Existing Uint8Array with a byte offset
 * new Int64(string)             - Hex string (throws if n is outside int64 range)
 * new Int64(number)             - Number (throws if n is outside int64 range)
 * new Int64(hi, lo)             - Raw bits as two 32-bit values
 */
var Int64 = module.exports = function(a1, a2) {
  if (a1 instanceof Buffer) {
    this.buffer = a1;
    this.offset = a2 || 0;
  } else if (Object.prototype.toString.call(a1) == '[object Uint8Array]') {
    // Under Browserify, Buffers can extend Uint8Arrays rather than an
    // instance of Buffer. We could assume the passed in Uint8Array is actually
    // a buffer but that won't handle the case where a raw Uint8Array is passed
    // in. We construct a new Buffer just in case.
    this.buffer = new Buffer(a1);
    this.offset = a2 || 0;
  } else {
    this.buffer = this.buffer || new Buffer(8);
    this.offset = 0;
    this.setValue.apply(this, arguments);
  }
};

// Max integer value that JS can accurately represent
Int64.MAX_INT = Math.pow(2, 53);

// Min integer value that JS can accurately represent
Int64.MIN_INT = -Math.pow(2, 53);

Int64.prototype = {

  constructor: Int64,

  /**
   * Do in-place 2's compliment.  See
   * http://en.wikipedia.org/wiki/Two's_complement
   */
  _2scomp: function() {
    var b = this.buffer, o = this.offset, carry = 1;
    for (var i = o + 7; i >= o; i--) {
      var v = (b[i] ^ 0xff) + carry;
      b[i] = v & 0xff;
      carry = v >> 8;
    }
  },

  /**
   * Set the value. Takes any of the following arguments:
   *
   * setValue(string) - A hexidecimal string
   * setValue(number) - Number (throws if n is outside int64 range)
   * setValue(hi, lo) - Raw bits as two 32-bit values
   */
  setValue: function(hi, lo) {
    var negate = false;
    if (arguments.length == 1) {
      if (typeof(hi) == 'number') {
        // Simplify bitfield retrieval by using abs() value.  We restore sign
        // later
        negate = hi < 0;
        hi = Math.abs(hi);
        lo = hi % VAL32;
        hi = hi / VAL32;
        if (hi > VAL32) throw new RangeError(hi  + ' is outside Int64 range');
        hi = hi | 0;
      } else if (typeof(hi) == 'string') {
        if( hi.length>=2 && hi[0]=='0' && hi[1]=='x' ) {
          hi = (hi + '').replace(/^0x/, '');
          lo = hi.substr(-8);
          hi = hi.length > 8 ? hi.substr(0, hi.length - 8) : '';
          hi = parseInt(hi, 16);
          lo = parseInt(lo, 16);
        } else {
          lo = hi.substr(-10);
          hi = hi.length > 10 ? hi.substr(0, hi.length - 10) : '';
          hi = parseInt(hi);
          lo = parseInt(lo);
        }
      } else {
        throw new Error(hi + ' must be a Number or String');
      }
    }

    // Technically we should throw if hi or lo is outside int32 range here, but
    // it's not worth the effort. Anything past the 32'nd bit is ignored.

    // Copy bytes to buffer
    var b = this.buffer, o = this.offset;
    for (var i = 7; i >= 0; i--) {
      b[o+i] = lo & 0xff;
      lo = i == 4 ? hi : lo >>> 8;
    }

    // Restore sign of passed argument
    if (negate) this._2scomp();
  },

  /**
   * Convert to a native JS number.
   *
   * WARNING: Do not expect this value to be accurate to integer precision for
   * large (positive or negative) numbers!
   *
   * @param allowImprecise If true, no check is performed to verify the
   * returned value is accurate to integer precision.  If false, imprecise
   * numbers (very large positive or negative numbers) will be forced to +/-
   * Infinity.
   */
  toNumber: function(allowImprecise) {
    var b = this.buffer, o = this.offset;

    // Running sum of octets, doing a 2's complement
    var negate = b[o] & 0x80, x = 0, carry = 1;
    for (var i = 7, m = 1; i >= 0; i--, m *= 256) {
      var v = b[o+i];

      // 2's complement for negative numbers
      if (negate) {
        v = (v ^ 0xff) + carry;
        carry = v >> 8;
        v = v & 0xff;
      }

      x += v * m;
    }

    // Return Infinity if we've lost integer precision
    if (!allowImprecise && x >= Int64.MAX_INT) {
      return negate ? -Infinity : Infinity;
    }

    return negate ? -x : x;
  },

  /**
   * Convert to a JS Number. Returns +/-Infinity for values that can't be
   * represented to integer precision.
   */
  valueOf: function() {
    return this.toNumber(false);
  },

  /**
   * Return string value
   *
   * @param radix Just like Number#toString()'s radix
   */
  toString: function(radix) {
    return this.valueOf().toString(radix || 10);
  },

  /**
   * Return a string showing the buffer octets, with MSB on the left.
   *
   * @param sep separator string. default is '' (empty string)
   */
  toOctetString: function(sep) {
    var out = new Array(8);
    var b = this.buffer, o = this.offset;
    for (var i = 0; i < 8; i++) {
      out[i] = _HEX[b[o+i]];
    }
    return out.join(sep || '');
  },

  /**
   * Returns the int64's 8 bytes in a buffer.
   *
   * @param {bool} [rawBuffer=false]  If no offset and this is true, return the internal buffer.  Should only be used if
   *                                  you're discarding the Int64 afterwards, as it breaks encapsulation.
   */
  toBuffer: function(rawBuffer) {
    if (rawBuffer && this.offset === 0) return this.buffer;

    var out = new Buffer(8);
    this.buffer.copy(out, 0, this.offset, this.offset + 8);
    return out;
  },

  /**
   * Copy 8 bytes of int64 into target buffer at target offset.
   *
   * @param {Buffer} targetBuffer       Buffer to copy into.
   * @param {number} [targetOffset=0]   Offset into target buffer.
   */
  copy: function(targetBuffer, targetOffset) {
    this.buffer.copy(targetBuffer, targetOffset || 0, this.offset, this.offset + 8);
  },

  /**
   * Returns a number indicating whether this comes before or after or is the
   * same as the other in sort order.
   *
   * @param {Int64} other  Other Int64 to compare.
   */
  compare: function(other) {

    // If sign bits differ ...
    if ((this.buffer[this.offset] & 0x80) != (other.buffer[other.offset] & 0x80)) {
      return other.buffer[other.offset] - this.buffer[this.offset];
    }

    // otherwise, compare bytes lexicographically
    for (var i = 0; i < 8; i++) {
      if (this.buffer[this.offset+i] !== other.buffer[other.offset+i]) {
        return this.buffer[this.offset+i] - other.buffer[other.offset+i];
      }
    }
    return 0;
  },

  /**
   * Returns a boolean indicating if this integer is equal to other.
   *
   * @param {Int64} other  Other Int64 to compare.
   */
  equals: function(other) {
    return this.compare(other) === 0;
  },

  /**
   * Pretty output in console.log
   */
  inspect: function() {
    return '[Int64 value:' + this + ' octets:' + this.toOctetString(' ') + ']';
  }
};

function main() {

    var n = stdin[0];
    n = parseInt(n);

    var b = stdin[1].split(' ').map( (s) => { return parseInt(s); });
    var a = [];
    a[0] = 0;
    a[n-1] = b[0];

    for(var i=1 ; i<n/2 ; i++) {
        if( b[i] < b[i-1] ) {
            a[i] = a[i-1];
            a[n-i-1] = b[i] - a[i];
        } else {
            a[n-i-1] = a[n-i];
            a[i] = b[i] - a[n-i-1];
        }
    }

    for(var i=0 ; i<n ; i++) {
        process.stdout.write(a[i] + " ");
    }
    //console.log(a);

}

const readline = require('readline');
const rl = readline.createInterface(process.stdin, process.stdout, null);

var stdin = [];
rl.on('line', function (line) {stdin.push(line);});
rl.on('close', main);