n = int(eval(input()))

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



p = [abs(li[i]-li[i+1]) for i in range(n-1)]

q = [abs(li[i]-li[i+2]) for i in range(n-2)]



dp = [0,p[0]]



for i in range(2,n):

    dp.append(min(dp[i-1]+p[i-1], dp[i-2]+q[i-2]))



print((dp[-1]))

n = int(eval(input()))

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



dp = [0]*n

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



for i in range(2, n):

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



print((dp[-1]))

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

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

-li = list(map(int, input().split())) -p = [abs(li[i] - li[i + 1]) for i in range(n - 1)] -q = [abs(li[i] - li[i + 2]) for i in range(n - 2)] -dp = [0, p[0]] +h = [int(i) for i in input().split()] +dp = [0] * n +dp[1] = abs(h[1] - h[0]) -    dp.append(min(dp[i - 1] + p[i - 1], dp[i - 2] + q[i - 2])) +    dp[i] = min(dp[i - 2] + abs(h[i] - h[i - 2]), dp[i - 1] + abs(h[i] - h[i - 1]))