while 1:a=raw_input().split();x=0;exec'y=int(a[~9]);a+=y-x,;x=y;'*110;print-x