26 lines
432 B
Python
26 lines
432 B
Python
|
import sys
|
||
|
|
||
|
L = sys.stdin.read().splitlines()
|
||
|
S = 0
|
||
|
for report in L:
|
||
|
l = [int(r) for r in report.split(' ')]
|
||
|
|
||
|
prem = [l[0]]
|
||
|
|
||
|
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])
|
||
|
l = list(m)
|
||
|
|
||
|
s = prem[0]
|
||
|
signe = -1
|
||
|
for a in prem[1:]:
|
||
|
s+=(a*signe)
|
||
|
signe *= -1
|
||
|
S+=s
|
||
|
|
||
|
|
||
|
print(S)
|