n = int(eval(input()))

h = [0]

for i in input().split(): h.append(int(i))

def cost(i,j): return abs(h[i]-h[j])



#dp[i]:= 足場iにたどり着く為の最小コスト

#dp[0]:= 0

#dp[1]:= 0

#dp[2]:= abs(h[1]-h[2])

dp = [0 for _ in range(n+1)]

dp[2] = cost(1,2)

for i in range(3,n+1):

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



print((dp[n]))
n = int(eval(input()))

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

INF = float("INF")

dp = [INF]*n

dp[0] = 0

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

for i in range(2,n):

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

print((dp[n-1]))
n = int(eval(input()))
h = [0]
for i in input().split():
    h.append(int(i))


def cost(i, j):
    return abs(h[i] - h[j])


# dp[i]:= 足場iにたどり着く為の最小コスト
# dp[0]:= 0
# dp[1]:= 0
# dp[2]:= abs(h[1]-h[2])
dp = [0 for _ in range(n + 1)]
dp[2] = cost(1, 2)
for i in range(3, n + 1):
    dp[i] = min(dp[i - 1] + cost(i, i - 1), dp[i - 2] + cost(i, i - 2))
print((dp[n]))

n = int(eval(input()))
h = [int(i) for i in input().split()]
INF = float("INF")
dp = [INF] * n
dp[0] = 0
dp[1] = abs(h[0] - h[1])
for i in range(2, n):
    dp[i] = min(dp[i - 2] + abs(h[i - 2] - h[i]), dp[i - 1] + abs(h[i - 1] - h[i]))
print((dp[n - 1]))

-h = [0] -for i in input().split(): -    h.append(int(i)) - - -def cost(i, j): -    return abs(h[i] - h[j]) - - -# dp[i]:= 足場iにたどり着く為の最小コスト -# dp[0]:= 0 -# dp[1]:= 0 -# dp[2]:= abs(h[1]-h[2]) -dp = [0 for _ in range(n + 1)] -dp[2] = cost(1, 2) -for i in range(3, n + 1): -    dp[i] = min(dp[i - 1] + cost(i, i - 1), dp[i - 2] + cost(i, i - 2)) -print((dp[n])) +h = [int(i) for i in input().split()] +INF = float("INF") +dp = [INF] * n +dp[0] = 0 +dp[1] = abs(h[0] - h[1]) +for i in range(2, n): +    dp[i] = min(dp[i - 2] + abs(h[i - 2] - h[i]), dp[i - 1] + abs(h[i - 1] - h[i])) +print((dp[n - 1]))