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