n = int(eval(input()))

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



DP = [10 ** 9] * n

DP[0] = 0



for i in range(1, n):

    DP[i] = min(DP[i], DP[i-1] + abs(H[i] - H[i-1]))

    if i > 1:

        DP[i] = min(DP[i], DP[i-2] + abs(H[i] - H[i-2]))

print((DP[-1]))
n = int(eval(input()))

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



memo = [0 for _ in range(n)]

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

for i in range(2, n):

  memo[i] = min(memo[i-1] + abs(H[i] - H[i-1]), memo[i-2] + abs(H[i] - H[i-2]))

print((memo[-1]))
n = int(eval(input()))
H = list(map(int, input().split()))
DP = [10**9] * n
DP[0] = 0
for i in range(1, n):
    DP[i] = min(DP[i], DP[i - 1] + abs(H[i] - H[i - 1]))
    if i > 1:
        DP[i] = min(DP[i], DP[i - 2] + abs(H[i] - H[i - 2]))
print((DP[-1]))

n = int(eval(input()))
H = list(map(int, input().split()))
memo = [0 for _ in range(n)]
memo[1] = abs(H[1] - H[0])
for i in range(2, n):
    memo[i] = min(
        memo[i - 1] + abs(H[i] - H[i - 1]), memo[i - 2] + abs(H[i] - H[i - 2])
    )
print((memo[-1]))

-DP = [10**9] * n -DP[0] = 0 -for i in range(1, n): -    DP[i] = min(DP[i], DP[i - 1] + abs(H[i] - H[i - 1])) -    if i > 1: -        DP[i] = min(DP[i], DP[i - 2] + abs(H[i] - H[i - 2])) -print((DP[-1])) +memo = [0 for _ in range(n)] +memo[1] = abs(H[1] - H[0]) +for i in range(2, n): +    memo[i] = min( +        memo[i - 1] + abs(H[i] - H[i - 1]), memo[i - 2] + abs(H[i] - H[i - 2]) +    ) +print((memo[-1]))