n = int(eval(input()))

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



C = [0]*(n)



for i in range(1, n):

  if i == 1:

    C[i] = abs(H[i]-H[i-1])

  else:

    C[i] = min(C[i-1]+abs(H[i]-H[i-1]), C[i-2]+abs(H[i]-H[i-2]))

  

print((C.pop()))
n = int(eval(input()))

H = [0]+list(map(int, input().split()))

dp = [0]*(n+1)

dp[2] = abs(H[2]-H[1])



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

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



print((dp[-1]))
n = int(eval(input()))
H = list(map(int, input().split()))
C = [0] * (n)
for i in range(1, n):
    if i == 1:
        C[i] = abs(H[i] - H[i - 1])
    else:
        C[i] = min(C[i - 1] + abs(H[i] - H[i - 1]), C[i - 2] + abs(H[i] - H[i - 2]))
print((C.pop()))

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

-H = list(map(int, input().split())) -C = [0] * (n) -for i in range(1, n): -    if i == 1: -        C[i] = abs(H[i] - H[i - 1]) -    else: -        C[i] = min(C[i - 1] + abs(H[i] - H[i - 1]), C[i - 2] + abs(H[i] - H[i - 2])) -print((C.pop())) +H = [0] + list(map(int, input().split())) +dp = [0] * (n + 1) +dp[2] = abs(H[2] - H[1]) +for i in range(3, n + 1): +    dp[i] = min(dp[i - 1] + abs(H[i] - H[i - 1]), dp[i - 2] + abs(H[i] - H[i - 2])) +print((dp[-1]))