while 1:a=map(int,raw_input().split());exec"a=map(int.__sub__,a[1:]+[0],a);"*len(a);print-a[0]