N = int(eval(input()))

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

for _ in range(10):

    H.append(10**9)

dp = [10**9] * (N+2)

dp[0] = 0

# 配る方式

for i in range(N):

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

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

print((dp[N-1]))



N = int(eval(input()))

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

for _ in range(10):

    H.append(10**9)

dp = [10**9] * (N+2)

dp[0] = 0

# 引っ張ってくる方式

for i in range(1, N):

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



print((dp[N-1]))



N = int(eval(input()))
H = list(map(int, input().split()))
for _ in range(10):
    H.append(10**9)
dp = [10**9] * (N + 2)
dp[0] = 0
# 配る方式
for i in range(N):
    dp[i + 1] = min(dp[i] + abs(H[i] - H[i + 1]), dp[i + 1])
    dp[i + 2] = min(dp[i] + abs(H[i] - H[i + 2]), dp[i + 2])
print((dp[N - 1]))

N = int(eval(input()))
H = list(map(int, input().split()))
for _ in range(10):
    H.append(10**9)
dp = [10**9] * (N + 2)
dp[0] = 0
# 引っ張ってくる方式
for i in range(1, N):
    dp[i] = min(dp[i - 1] + abs(H[i] - H[i - 1]), dp[i - 2] + abs(H[i] - H[i - 2]))
print((dp[N - 1]))

-# 配る方式 -for i in range(N): -    dp[i + 1] = min(dp[i] + abs(H[i] - H[i + 1]), dp[i + 1]) -    dp[i + 2] = min(dp[i] + abs(H[i] - H[i + 2]), dp[i + 2]) +# 引っ張ってくる方式 +for i in range(1, N): +    dp[i] = min(dp[i - 1] + abs(H[i] - H[i - 1]), dp[i - 2] + abs(H[i] - H[i - 2]))