inf = float('inf')



n = int(eval(input()))

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



dp = [inf] * n

dp[0] = 0



for i in range(n):

    for j in 2, 1:

        if i + j < n:

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



print((dp[n - 1]))

inf = float('inf')



n = int(eval(input()))

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



dp = [inf] * (n + 1)

dp[0] = 0



# 配る

for i in range(n - 1):

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

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

print((dp[n - 1]))

inf = float("inf")
n = int(eval(input()))
h = list(map(int, input().split()))
dp = [inf] * n
dp[0] = 0
for i in range(n):
    for j in 2, 1:
        if i + j < n:
            dp[i + j] = min(dp[i + j], dp[i] + abs(h[i + j] - h[i]))
print((dp[n - 1]))

inf = float("inf")
n = int(eval(input()))
h = list(map(int, input().split())) + [inf]
dp = [inf] * (n + 1)
dp[0] = 0
# 配る
for i in range(n - 1):
    dp[i + 1] = min(dp[i + 1], dp[i] + abs(h[i + 1] - h[i]))
    dp[i + 2] = min(dp[i + 2], dp[i] + abs(h[i + 2] - h[i]))
print((dp[n - 1]))

-h = list(map(int, input().split())) -dp = [inf] * n +h = list(map(int, input().split())) + [inf] +dp = [inf] * (n + 1) -for i in range(n): -    for j in 2, 1: -        if i + j < n: -            dp[i + j] = min(dp[i + j], dp[i] + abs(h[i + j] - h[i])) +# 配る +for i in range(n - 1): +    dp[i + 1] = min(dp[i + 1], dp[i] + abs(h[i + 1] - h[i])) +    dp[i + 2] = min(dp[i + 2], dp[i] + abs(h[i + 2] - h[i]))