n = int(eval(input()))

ls_h = list(map(int,input().split()))

ls_cos = [0]*n

ls_cos[1] = abs(ls_h[1]-ls_h[0])

for i in range(2,n):

    ls_cos[i] = min(ls_cos[i-2]+abs(ls_h[i]-ls_h[i-2]) , ls_cos[i-1]+abs(ls_h[i]-ls_h[i-1]))



print((ls_cos[-1]))



n = int(eval(input()))

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

ans = [0,abs(h[1]-h[0])]+[0]*(n-2)

for i in range(2,n):

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

print((ans[-1]))
n = int(eval(input()))
ls_h = list(map(int, input().split()))
ls_cos = [0] * n
ls_cos[1] = abs(ls_h[1] - ls_h[0])
for i in range(2, n):
    ls_cos[i] = min(
        ls_cos[i - 2] + abs(ls_h[i] - ls_h[i - 2]),
        ls_cos[i - 1] + abs(ls_h[i] - ls_h[i - 1]),
    )
print((ls_cos[-1]))

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

-ls_h = list(map(int, input().split())) -ls_cos = [0] * n -ls_cos[1] = abs(ls_h[1] - ls_h[0]) +h = list(map(int, input().split())) +ans = [0, abs(h[1] - h[0])] + [0] * (n - 2) -    ls_cos[i] = min( -        ls_cos[i - 2] + abs(ls_h[i] - ls_h[i - 2]), -        ls_cos[i - 1] + abs(ls_h[i] - ls_h[i - 1]), -    ) -print((ls_cos[-1])) +    ans[i] = min(ans[i - 1] + abs(h[i] - h[i - 1]), ans[i - 2] + abs(h[i] - h[i - 2])) +print((ans[-1]))