n = int(eval(input()))

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



dp = [10**8] * n



for i in range(n):

    if i == 0:

        dp[i] = 0

    elif i == 1:

        dp[i] = abs(li[i] - li[i-1])

    else:

        dp[i] = min(abs(li[i] - li[i-1]) + dp[i-1], abs(li[i] - li[i-2]) + dp[i-2])



print((dp[-1]))

n = int(eval(input()))

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



dp = [10**18] * n

dp[0] = 0

for i in range(1,n):

    if i == 1:

        dp[i] = abs(h_li[i] - h_li[0])

    else:

        dp[i] = min(abs(h_li[i] - h_li[i-1]) + dp[i-1], abs(h_li[i] - h_li[i-2]) + dp[i-2])



print((dp[-1]))
n = int(eval(input()))
li = list(map(int, input().split()))
dp = [10**8] * n
for i in range(n):
    if i == 0:
        dp[i] = 0
    elif i == 1:
        dp[i] = abs(li[i] - li[i - 1])
    else:
        dp[i] = min(
            abs(li[i] - li[i - 1]) + dp[i - 1], abs(li[i] - li[i - 2]) + dp[i - 2]
        )
print((dp[-1]))

n = int(eval(input()))
h_li = list(map(int, input().split()))
dp = [10**18] * n
dp[0] = 0
for i in range(1, n):
    if i == 1:
        dp[i] = abs(h_li[i] - h_li[0])
    else:
        dp[i] = min(
            abs(h_li[i] - h_li[i - 1]) + dp[i - 1],
            abs(h_li[i] - h_li[i - 2]) + dp[i - 2],
        )
print((dp[-1]))

-li = list(map(int, input().split())) -dp = [10**8] * n -for i in range(n): -    if i == 0: -        dp[i] = 0 -    elif i == 1: -        dp[i] = abs(li[i] - li[i - 1]) +h_li = list(map(int, input().split())) +dp = [10**18] * n +dp[0] = 0 +for i in range(1, n): +    if i == 1: +        dp[i] = abs(h_li[i] - h_li[0]) -            abs(li[i] - li[i - 1]) + dp[i - 1], abs(li[i] - li[i - 2]) + dp[i - 2] +            abs(h_li[i] - h_li[i - 1]) + dp[i - 1], +            abs(h_li[i] - h_li[i - 2]) + dp[i - 2],