n = int(eval(input()))

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



#dp = [float("inf")] * (10**4 + 1)

dp = [10**9] * n



dp[0] = 0

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



for i in range(2,n):

    #dp[i]

    # 1

    tmp1 = dp[i-1] + abs(h_L[i-1] - h_L[i])

    #dp[i] = min(dp[i],tmp1)

    # 2

    tmp2 = dp[i-2] + abs(h_L[i-2] - h_L[i])

    dp[i] = min(dp[i],tmp1,tmp2)

#print(dp)

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

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



dp = [0] * (n+1)

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



for i in range(n-2):

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



print((dp[n-1]))
n = int(eval(input()))
h_L = list(map(int, input().split()))
# dp = [float("inf")] * (10**4 + 1)
dp = [10**9] * n
dp[0] = 0
dp[1] = abs(h_L[0] - h_L[1])
for i in range(2, n):
    # dp[i]
    # 1
    tmp1 = dp[i - 1] + abs(h_L[i - 1] - h_L[i])
    # dp[i] = min(dp[i],tmp1)
    # 2
    tmp2 = dp[i - 2] + abs(h_L[i - 2] - h_L[i])
    dp[i] = min(dp[i], tmp1, tmp2)
# print(dp)
print((dp[n - 1]))

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

-# dp = [float("inf")] * (10**4 + 1) -dp = [10**9] * n -dp[0] = 0 -dp[1] = abs(h_L[0] - h_L[1]) -for i in range(2, n): -    # dp[i] -    # 1 -    tmp1 = dp[i - 1] + abs(h_L[i - 1] - h_L[i]) -    # dp[i] = min(dp[i],tmp1) -    # 2 -    tmp2 = dp[i - 2] + abs(h_L[i - 2] - h_L[i]) -    dp[i] = min(dp[i], tmp1, tmp2) -# print(dp) +dp = [0] * (n + 1) +dp[1] = abs(h_L[1] - h_L[0]) +for i in range(n - 2): +    dp[i + 2] = min( +        dp[i + 1] + abs(h_L[i + 2] - h_L[i + 1]), dp[i] + abs(h_L[i + 2] - h_L[i]) +    )