n = int(eval(input()))

h = [0] + list(map(int, input().split()))

cost = {1:0,2: abs(h[2] - h[1])}

for i in range(1, n):

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

    if i==n-1:break

    cost[i + 2] = cost[i] + abs(h[i + 2] - h[i])



print((cost[n]))

n = int(eval(input()))

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

dp = [0] * n

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

for i, (h, h1, h2) in enumerate(zip(h[2:], h[1:], h)):

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

print((dp[-1]))

n = int(eval(input()))
h = [0] + list(map(int, input().split()))
cost = {1: 0, 2: abs(h[2] - h[1])}
for i in range(1, n):
    cost[i + 1] = min(cost[i + 1], cost[i] + abs(h[i + 1] - h[i]))
    if i == n - 1:
        break
    cost[i + 2] = cost[i] + abs(h[i + 2] - h[i])
print((cost[n]))

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

-h = [0] + list(map(int, input().split())) -cost = {1: 0, 2: abs(h[2] - h[1])} -for i in range(1, n): -    cost[i + 1] = min(cost[i + 1], cost[i] + abs(h[i + 1] - h[i])) -    if i == n - 1: -        break -    cost[i + 2] = cost[i] + abs(h[i + 2] - h[i]) -print((cost[n])) +h = list(map(int, input().split())) +dp = [0] * n +dp[1] = abs(h[1] - h[0]) +for i, (h, h1, h2) in enumerate(zip(h[2:], h[1:], h)): +    dp[i + 2] = min(dp[i + 1] + abs(h - h1), dp[i] + abs(h - h2)) +print((dp[-1]))