n = int(eval(input()))

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

cost = [0] * (n + 1)



for i in range(n):

    if i == 0:

        continue

    elif i == 1:

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

        continue



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

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



print((cost[n-1]))

n = int(eval(input()))

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

cost = [0] * (n + 1)



inf = 10**18

dp = [inf]*(n+5)

dp[0] = 0

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



for i in range(2, n):

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



ans = dp[n-1]

print(ans)

n = int(eval(input()))
h = tuple(map(int, input().split()))
cost = [0] * (n + 1)
for i in range(n):
    if i == 0:
        continue
    elif i == 1:
        cost[i] = cost[i - 1] + abs(h[i] - h[i - 1])
        continue
    cost[i] = min(
        cost[i - 1] + abs(h[i] - h[i - 1]), cost[i - 2] + abs(h[i] - h[i - 2])
    )
print((cost[n - 1]))

n = int(eval(input()))
h = tuple(map(int, input().split()))
cost = [0] * (n + 1)
inf = 10**18
dp = [inf] * (n + 5)
dp[0] = 0
dp[1] = abs(h[1] - h[0])
for i in range(2, n):
    dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2]))
ans = dp[n - 1]
print(ans)

-for i in range(n): -    if i == 0: -        continue -    elif i == 1: -        cost[i] = cost[i - 1] + abs(h[i] - h[i - 1]) -        continue -    cost[i] = min( -        cost[i - 1] + abs(h[i] - h[i - 1]), cost[i - 2] + abs(h[i] - h[i - 2]) -    ) -print((cost[n - 1])) +inf = 10**18 +dp = [inf] * (n + 5) +dp[0] = 0 +dp[1] = abs(h[1] - h[0]) +for i in range(2, n): +    dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2])) +ans = dp[n - 1] +print(ans)