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 - k] + abs(h[i]-h[i-k]) for k in [1, 2])



print((dp[-1]))
n = int(eval(input()))

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



dp = [10 ** 12] * (n)

dp[0] = 0

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



for i in range(1, n-1):

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

  

ans = dp[n-1]



print(ans)
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 - k] + abs(h[i] - h[i - k]) for k in [1, 2])
print((dp[-1]))

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

-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 - k] + abs(h[i] - h[i - k]) for k in [1, 2]) -print((dp[-1])) +H = list(map(int, input().split())) +dp = [10**12] * (n) +dp[0] = 0 +dp[1] = abs(H[1] - H[0]) +for i in range(1, n - 1): +    dp[i + 1] = min(dp[i] + abs(H[i + 1] - H[i]), dp[i - 1] + abs(H[i + 1] - H[i - 1])) +ans = dp[n - 1] +print(ans)