while 1: v=map(int,raw_input().split());t=0 while v:t+=v[-1];v=[b-a for a,b in zip(v,v[1:])] print t