N = int(eval(input()))

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

 

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

for i in range(N-2):

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

 

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

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



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

for i in range(2, n):

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

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

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

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