N = int(eval(input()))

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



DP = [0]*N

DP[1] = abs(High[0]-High[1])

for i in range(2, N):

    DP[i] = min(DP[i-2] + abs(High[i] - High[i - 2]), DP[i-1] + abs(High[i] - High[i - 1]))



print((DP[N-1]))
N = int(eval(input()))

H = [float('inf')] + list(map(int, input().split()))

DP = [0] * (N+1)



for i in range(2, N+1):

    DP[i] = min(abs(H[i] - H[i-1]) + DP[i-1], abs(H[i] - H[i-2]) + DP[i-2])

print((DP[N]))

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

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

-High = list(map(int, input().split())) -DP = [0] * N -DP[1] = abs(High[0] - High[1]) -for i in range(2, N): -    DP[i] = min( -        DP[i - 2] + abs(High[i] - High[i - 2]), DP[i - 1] + abs(High[i] - High[i - 1]) -    ) -print((DP[N - 1])) +H = [float("inf")] + list(map(int, input().split())) +DP = [0] * (N + 1) +for i in range(2, N + 1): +    DP[i] = min(abs(H[i] - H[i - 1]) + DP[i - 1], abs(H[i] - H[i - 2]) + DP[i - 2]) +print((DP[N]))