import numpy as np

N = int(eval(input()))

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

inf = float("inf")

dp = np.full(N, inf, dtype=int)

dp[0] = 0

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

for i in range(2, N):

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

print((dp[-1]))

N = int(eval(input()))

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

dp = [0] * N

dp[0] = 0

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

for i in range(2, N):

    cost1 = dp[i - 1] + abs(hlist[i] - hlist[i - 1])

    cost2 = dp[i - 2] + abs(hlist[i] - hlist[i - 2])

    dp[i] = min(cost1, cost2)



print((dp[-1]))

import numpy as np

N = int(eval(input()))
hlist = list(map(int, input().split()))
inf = float("inf")
dp = np.full(N, inf, dtype=int)
dp[0] = 0
dp[1] = abs(hlist[1] - hlist[0])
for i in range(2, N):
    dp[i] = min(
        dp[i - 2] + abs(hlist[i - 2] - hlist[i]),
        dp[i - 1] + abs(hlist[i - 1] - hlist[i]),
    )
print((dp[-1]))

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

-import numpy as np - -inf = float("inf") -dp = np.full(N, inf, dtype=int) +dp = [0] * N -dp[1] = abs(hlist[1] - hlist[0]) +dp[1] = abs(hlist[0] - hlist[1]) -    dp[i] = min( -        dp[i - 2] + abs(hlist[i - 2] - hlist[i]), -        dp[i - 1] + abs(hlist[i - 1] - hlist[i]), -    ) +    cost1 = dp[i - 1] + abs(hlist[i] - hlist[i - 1]) +    cost2 = dp[i - 2] + abs(hlist[i] - hlist[i - 2]) +    dp[i] = min(cost1, cost2)