n = int(eval(input()))

h = [int(_) for _ in input().split()]

mc = [0, abs(h[0]-h[1])] #足場1, 2に辿り着くまでに支払うコストの最小値

for i in range(2,n):

    mc.append(min(mc[i-2]+abs(h[i-2]-h[i]), mc[i-1]+abs(h[i-1]-h[i])))

print((mc[n-1]))

n=int(eval(input()))

h=[int(_) for _ in input().split()]

mc=[0,abs(h[0]-h[1])]

for i in range(2,n):mc.append(min(mc[i-2]+abs(h[i-2]-h[i]),mc[i-1]+abs(h[i-1]-h[i])))

print((mc[n-1]))
n = int(eval(input()))
h = [int(_) for _ in input().split()]
mc = [0, abs(h[0] - h[1])]  # 足場1, 2に辿り着くまでに支払うコストの最小値
for i in range(2, n):
    mc.append(min(mc[i - 2] + abs(h[i - 2] - h[i]), mc[i - 1] + abs(h[i - 1] - h[i])))
print((mc[n - 1]))

n = int(eval(input()))
h = [int(_) for _ in input().split()]
mc = [0, abs(h[0] - h[1])]
for i in range(2, n):
    mc.append(min(mc[i - 2] + abs(h[i - 2] - h[i]), mc[i - 1] + abs(h[i - 1] - h[i])))
print((mc[n - 1]))

-mc = [0, abs(h[0] - h[1])]  # 足場1, 2に辿り着くまでに支払うコストの最小値 +mc = [0, abs(h[0] - h[1])]