n = int(eval(input()))

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

h_ls = h_ls



# ここからはh_lsのインデックスを基準に

one_cost = [0] * (n)

for i in range(n-1):

    one_cost[i+1] = abs(h_ls[i+1] - h_ls[i])

two_cost = [0] * (n)

for i in range(n-2):

    two_cost[i+2] = abs(h_ls[i+2] - h_ls[i])



mincost_ls = [0] * (n)

mincost_ls[1] = one_cost[1]

for i in range(n-2):

    mincost_ls[i+2] = min(mincost_ls[i+1] + one_cost[i+2], mincost_ls[i] + two_cost[i+2])

print((mincost_ls[-1]))

n = int(eval(input()))

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

h_ls = h_ls



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

mincost_ls[0] = 0

mincost_ls[1] = abs(h_ls[1] - h_ls[0])

for i in range(n-2):

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

        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()))
h_ls = h_ls
# ここからはh_lsのインデックスを基準に
one_cost = [0] * (n)
for i in range(n - 1):
    one_cost[i + 1] = abs(h_ls[i + 1] - h_ls[i])
two_cost = [0] * (n)
for i in range(n - 2):
    two_cost[i + 2] = abs(h_ls[i + 2] - h_ls[i])
mincost_ls = [0] * (n)
mincost_ls[1] = one_cost[1]
for i in range(n - 2):
    mincost_ls[i + 2] = min(
        mincost_ls[i + 1] + one_cost[i + 2], mincost_ls[i] + two_cost[i + 2]
    )
print((mincost_ls[-1]))

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

-# ここからはh_lsのインデックスを基準に -one_cost = [0] * (n) -for i in range(n - 1): -    one_cost[i + 1] = abs(h_ls[i + 1] - h_ls[i]) -two_cost = [0] * (n) -for i in range(n - 2): -    two_cost[i + 2] = abs(h_ls[i + 2] - h_ls[i]) -mincost_ls = [0] * (n) -mincost_ls[1] = one_cost[1] +mincost_ls = [float("inf")] * n +mincost_ls[0] = 0 +mincost_ls[1] = abs(h_ls[1] - h_ls[0]) -        mincost_ls[i + 1] + one_cost[i + 2], mincost_ls[i] + two_cost[i + 2] +        mincost_ls[i + 1] + abs(h_ls[i + 2] - h_ls[i + 1]), +        mincost_ls[i] + abs(h_ls[i + 2] - h_ls[i]),