N = int(eval(input()))

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



dp = [[] for i in range(N)]

dp[0] = 0

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



for i in range(1,N-1):

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

  

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

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



dp = [0]*n

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



for i in range(2, n):

  be1 = abs(cost[i]-cost[i-1])

  be2 = abs(cost[i]-cost[i-2])

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

  

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

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

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