N = int(eval(input()))

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

B = [0]*N

B[1]=abs(H[1]-H[0])

for i in range(2, N):

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

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

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



dp =[0]*N



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



for i in range(2, N):

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



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

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

-B = [0] * N -B[1] = abs(H[1] - H[0]) +dp = [0] * N +dp[1] = abs(H[1] - H[0]) -    B[i] = min(B[i - 2] + abs(H[i] - H[i - 2]), B[i - 1] + abs(H[i] - H[i - 1])) -print((B[N - 1])) +    dp[i] = min(dp[i - 2] + abs(H[i - 2] - H[i]), dp[i - 1] + abs(H[i - 1] - H[i])) +print((dp[-1]))