n = int(eval(input()))

h = tuple(int(i) for i in input().split())

x, y = 0, abs(h[0]-h[1])

for i in range(2, n):

    v = min(x+abs(h[i-2]-h[i]), y+abs(h[i-1]-h[i]))

    x, y = y, v

print(y)
n = int(eval(input()))

h = tuple(map(int, input().split()))

x, y = 0, abs(h[0]-h[1])

for i in range(2, n):

    d1 = x+abs(h[i-2]-h[i])

    d2 = y+abs(h[i-1]-h[i])

    x, y = y, d1 if d1 < d2 else d2

print(y)
n = int(eval(input()))
h = tuple(int(i) for i in input().split())
x, y = 0, abs(h[0] - h[1])
for i in range(2, n):
    v = min(x + abs(h[i - 2] - h[i]), y + abs(h[i - 1] - h[i]))
    x, y = y, v
print(y)

n = int(eval(input()))
h = tuple(map(int, input().split()))
x, y = 0, abs(h[0] - h[1])
for i in range(2, n):
    d1 = x + abs(h[i - 2] - h[i])
    d2 = y + abs(h[i - 1] - h[i])
    x, y = y, d1 if d1 < d2 else d2
print(y)

-h = tuple(int(i) for i in input().split()) +h = tuple(map(int, input().split())) -    v = min(x + abs(h[i - 2] - h[i]), y + abs(h[i - 1] - h[i])) -    x, y = y, v +    d1 = x + abs(h[i - 2] - h[i]) +    d2 = y + abs(h[i - 1] - h[i]) +    x, y = y, d1 if d1 < d2 else d2