N = int(eval(input()))

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



INF = 10 ** 9 + 1

dp = [INF] * N

dp[0] = 0

for i in range(len(dp) - 1):

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

  if i + 2 < len(dp):

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

  

print((dp[N - 1]))

N = int(eval(input()))

blank = 2

h = list(map(int,input().split())) + [0] * blank



INF = 10 ** 9 + 1

dp = [INF] * (N + blank)

dp[0] = 0

for i in range(N):

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

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

  

print((dp[N - 1]))

N = int(eval(input()))
h = list(map(int, input().split()))
INF = 10**9 + 1
dp = [INF] * N
dp[0] = 0
for i in range(len(dp) - 1):
    dp[i + 1] = min(dp[i] + abs(h[i + 1] - h[i]), dp[i + 1])
    if i + 2 < len(dp):
        dp[i + 2] = min(dp[i] + abs(h[i + 2] - h[i]), dp[i + 2])
print((dp[N - 1]))

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

-h = list(map(int, input().split())) +blank = 2 +h = list(map(int, input().split())) + [0] * blank -dp = [INF] * N +dp = [INF] * (N + blank) -for i in range(len(dp) - 1): +for i in range(N): -    if i + 2 < len(dp): -        dp[i + 2] = min(dp[i] + abs(h[i + 2] - h[i]), dp[i + 2]) +    dp[i + 2] = min(dp[i] + abs(h[i + 2] - h[i]), dp[i + 2])