"""

dp[i] := 足場iまでにかかるコストの最小値

"""

N = int(eval(input()))

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

dp = [0 for _ in range(N)]

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



for i in range(2, N):

    case1 = dp[i-1] + abs(h[i-1] - h[i])

    case2 = dp[i-2] + abs(h[i-2] - h[i])

    dp[i] = min(case1, case2)



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

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



cost = [0]*N

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



for k in range(2, N):

    cost[k] = min(cost[k-1] + abs(H[k-1] - H[k]), cost[k-2] + abs(H[k-2] - H[k]))





print((cost[-1]))
"""
dp[i] := 足場iまでにかかるコストの最小値
"""
N = int(eval(input()))
(*h,) = list(map(int, input().split()))
dp = [0 for _ in range(N)]
dp[1] = abs(h[0] - h[1])  # initialize dp
for i in range(2, N):
    case1 = dp[i - 1] + abs(h[i - 1] - h[i])
    case2 = dp[i - 2] + abs(h[i - 2] - h[i])
    dp[i] = min(case1, case2)
print((dp[-1]))

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

-""" -dp[i] := 足場iまでにかかるコストの最小値 -""" -(*h,) = list(map(int, input().split())) -dp = [0 for _ in range(N)] -dp[1] = abs(h[0] - h[1])  # initialize dp -for i in range(2, N): -    case1 = dp[i - 1] + abs(h[i - 1] - h[i]) -    case2 = dp[i - 2] + abs(h[i - 2] - h[i]) -    dp[i] = min(case1, case2) -print((dp[-1])) +H = list(map(int, input().split())) +cost = [0] * N +cost[1] = abs(H[0] - H[1]) +for k in range(2, N): +    cost[k] = min( +        cost[k - 1] + abs(H[k - 1] - H[k]), cost[k - 2] + abs(H[k - 2] - H[k]) +    ) +print((cost[-1]))