import sys L = sys.stdin.read().splitlines() S = 0 l = [0, 3, 6, 9, 12, 15] #-3 #l = [1, 3, 6, 10, 15, 21] #0 l = [10, 13, 16, 21, 30, 45] #l = [-6, -9, -13, -18] m = list(l) prem=[] prem.append(m[0]) print(m) while not all(v == 0 for v in l): m = [] for i in range(0,len(l)-1): m.append(l[i+1] - l[i]) prem.append(m[0]) print(m) l = list(m) s = prem[0] signe = -1 for a in prem[1:]: s+=(a*signe) signe *= -1 print(s) S+=s #print(sum(prem)) print(S)