n = int(eval(input()))

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

hlis.append(float('inf'))

dp = [0] + [abs(hlis[0] - hlis[1])] + [float('inf')]*(n-1)

for i in range(n-1):

    one = abs(hlis[i]-hlis[i+1])

    two = abs(hlis[i]-hlis[i+2])

    dp[i+1] = min(dp[i]+one, dp[i+1])

    dp[i+2] = min(dp[i]+two, dp[i+2])

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

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

dp = [-1]*N

dp[0] = 0

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

for i in range(2, N):

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

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

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

-n = int(eval(input())) +N = int(eval(input())) -hlis.append(float("inf")) -dp = [0] + [abs(hlis[0] - hlis[1])] + [float("inf")] * (n - 1) -for i in range(n - 1): -    one = abs(hlis[i] - hlis[i + 1]) -    two = abs(hlis[i] - hlis[i + 2]) -    dp[i + 1] = min(dp[i] + one, dp[i + 1]) -    dp[i + 2] = min(dp[i] + two, dp[i + 2]) -print((dp[n - 1])) +dp = [-1] * N +dp[0] = 0 +dp[1] = abs(hlis[0] - hlis[1]) +for i in range(2, N): +    dp[i] = min( +        dp[i - 1] + abs(hlis[i] - hlis[i - 1]), dp[i - 2] + abs(hlis[i] - hlis[i - 2]) +    ) +print((dp[-1]))