n = int(eval(input()))

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



c = [0] * n

c[0] = 0

c[1] = abs(h[0] - h[1])



for i in range(2, n):

    c[i] = min(c[i - 1] + abs(h[i - 1] - h[i]), c[i - 2] + abs(h[i - 2] - h[i]))



print((c[-1]))

n = int(eval(input()))

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



a, b = 0, abs(hs[1] - hs[0])



for i in range(2, n):

  c = hs[i]

  a, b = b, min(a + abs(c - hs[i-2]), b + abs(c - hs[i-1]))



print(b)

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

n = int(eval(input()))
hs = tuple(map(int, input().split()))
a, b = 0, abs(hs[1] - hs[0])
for i in range(2, n):
    c = hs[i]
    a, b = b, min(a + abs(c - hs[i - 2]), b + abs(c - hs[i - 1]))
print(b)

-h = tuple(map(int, input().split())) -c = [0] * n -c[0] = 0 -c[1] = abs(h[0] - h[1]) +hs = tuple(map(int, input().split())) +a, b = 0, abs(hs[1] - hs[0]) -    c[i] = min(c[i - 1] + abs(h[i - 1] - h[i]), c[i - 2] + abs(h[i - 2] - h[i])) -print((c[-1])) +    c = hs[i] +    a, b = b, min(a + abs(c - hs[i - 2]), b + abs(c - hs[i - 1])) +print(b)