n = int(eval(input()))

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



cost = [0] * n

cost[0] = 0

cost[1] = abs(hl[0] - hl[1])



for i in range(2, n):

    cost[i] = (min(cost[i-1] + abs(hl[i] - hl[i-1]),

                       (cost[i-2] + abs(hl[i] - hl[i-2]))))





print((cost[-1]))
n = int(eval(input()))

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



cost = [1001001001] * n

cost[0] = 0

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



for i in range(2, n):

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

                  cost[i-1] + abs(h[i] - h[i-1]))



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

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

-hl = list(map(int, input().split())) -cost = [0] * n +h = list(map(int, input().split())) +cost = [1001001001] * n -cost[1] = abs(hl[0] - hl[1]) +cost[1] = abs(h[1] - h[0]) -        cost[i - 1] + abs(hl[i] - hl[i - 1]), (cost[i - 2] + abs(hl[i] - hl[i - 2])) +        (cost[i - 2] + abs(h[i] - h[i - 2])), cost[i - 1] + abs(h[i] - h[i - 1])