N = int(eval(input()))

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

dp = [0] * (N+10)

dp[2] = abs(A[1] - A[0])

for i in range(2,N):

    Ai = abs(A[i] - A[i-1])

    Ai2 = abs(A[i] - A[i-2])

    dp[i+1] = min(dp[i]+Ai,dp[i-1]+Ai2)



print((dp[N]))
N = int(eval(input()))

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

dp = [0] * N

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

for i in range(2,N):

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

print((dp[-1]))

N = int(eval(input()))
A = list(map(int, input().split()))
dp = [0] * (N + 10)
dp[2] = abs(A[1] - A[0])
for i in range(2, N):
    Ai = abs(A[i] - A[i - 1])
    Ai2 = abs(A[i] - A[i - 2])
    dp[i + 1] = min(dp[i] + Ai, dp[i - 1] + Ai2)
print((dp[N]))

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

-A = list(map(int, input().split())) -dp = [0] * (N + 10) -dp[2] = abs(A[1] - A[0]) +h = list(map(int, input().split())) +dp = [0] * N +dp[1] = abs(h[0] - h[1]) -    Ai = abs(A[i] - A[i - 1]) -    Ai2 = abs(A[i] - A[i - 2]) -    dp[i + 1] = min(dp[i] + Ai, dp[i - 1] + Ai2) -print((dp[N])) +    dp[i] = min(dp[i - 1] + abs(h[i - 1] - h[i]), dp[i - 2] + abs(h[i - 2] - h[i])) +print((dp[-1]))