N = int(eval(input()))

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

#コストの配列 全部無限にしておく

cost = [float("inf") for _ in range(N)]

cost[0] = 0

for i in range(N-1):

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

    if(i + 2 < N):

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

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

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

dp = [0] * N

dp[0] = 0;

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

for i in range(2, N):

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

print((dp[N-1]))
N = int(eval(input()))
A = list(map(int, input().split()))
# コストの配列 全部無限にしておく
cost = [float("inf") for _ in range(N)]
cost[0] = 0
for i in range(N - 1):
    cost[i + 1] = min(cost[i + 1], cost[i] + abs(A[i + 1] - A[i]))
    if i + 2 < N:
        cost[i + 2] = min(cost[i + 2], cost[i] + abs(A[i + 2] - A[i]))
print((cost[N - 1]))

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

-A = list(map(int, input().split())) -# コストの配列 全部無限にしておく -cost = [float("inf") for _ in range(N)] -cost[0] = 0 -for i in range(N - 1): -    cost[i + 1] = min(cost[i + 1], cost[i] + abs(A[i + 1] - A[i])) -    if i + 2 < N: -        cost[i + 2] = min(cost[i + 2], cost[i] + abs(A[i + 2] - A[i])) -print((cost[N - 1])) +h = list(map(int, input().split())) +dp = [0] * N +dp[0] = 0 +dp[1] = abs(h[1] - h[0]) +for i in range(2, N): +    dp[i] = min(abs(h[i] - h[i - 1]) + dp[i - 1], abs(h[i] - h[i - 2]) + dp[i - 2]) +print((dp[N - 1]))