n = int(eval(input()))

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

dp = [float('inf') for _ in range(n)]

dp[0] = 0

for i in range(n-1):

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

    if i < n - 2:

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

print((dp[-1]))

n = int(eval(input()))

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

mincost_ls = [float('inf')] * n

mincost_ls[0] = 0

for i in range(n-1):

    mincost_ls[i+1] = min(mincost_ls[i+1], mincost_ls[i]+abs(h_ls[i+1]-h_ls[i]))

    if i+2 < n:

        mincost_ls[i+2] = min(mincost_ls[i+2], mincost_ls[i]+abs(h_ls[i+2]-h_ls[i]))

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

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

-dp = [float("inf") for _ in range(n)] -dp[0] = 0 +mincost_ls = [float("inf")] * n +mincost_ls[0] = 0 -    dp[i + 1] = min(dp[i + 1], dp[i] + abs(h_ls[i + 1] - h_ls[i])) -    if i < n - 2: -        dp[i + 2] = min(dp[i + 2], dp[i] + abs(h_ls[i + 2] - h_ls[i])) -print((dp[-1])) +    mincost_ls[i + 1] = min( +        mincost_ls[i + 1], mincost_ls[i] + abs(h_ls[i + 1] - h_ls[i]) +    ) +    if i + 2 < n: +        mincost_ls[i + 2] = min( +            mincost_ls[i + 2], mincost_ls[i] + abs(h_ls[i + 2] - h_ls[i]) +        ) +print((mincost_ls[-1]))