import numpy as np

n = int(eval(input()))

k = 2

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

dp = np.array([0]*n)



for i in range(1,n):

  s = max(i-k,0)

  dp[i] = np.min(dp[s:i]+np.abs(h[s:i]-h[i]))

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

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

#print(l)

dp = [0]*n

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

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

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

print((dp[-1]))
import numpy as np

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

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

-import numpy as np - -k = 2 -h = np.array(list(map(int, input().split()))) -dp = np.array([0] * n) -for i in range(1, n): -    s = max(i - k, 0) -    dp[i] = np.min(dp[s:i] + np.abs(h[s:i] - h[i])) -print((dp[n - 1])) +l = list(map(int, input().split())) +# print(l) +dp = [0] * n +dp[1] = abs(l[1] - l[0]) +for i in range(1, n - 1): +    dp[i + 1] = min(dp[i] + abs(l[i + 1] - l[i]), dp[i - 1] + abs(l[i + 1] - l[i - 1])) +print((dp[-1]))