dp=[]

#iまでに要したminコスト

#dp[i] = dp[i-1]+abs(l[i]-l[i-1]) or dp[i-2]+abs(l[i+1]-l[i-1])



n = int(eval(input()))

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

dp.append(0) #dp[0]

dp.append(abs(l[1]-l[0])) #dp[1]



for i in range(2, n):

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

    dp.append(new) 





ans = min((dp[n-2]+abs(l[n-2]-l[n-1])), (dp[n-3] + abs(l[n-3]-l[n-1])))

print(ans)
N = int(eval(input()))

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



dp = [10**100] * (N+2)

dp[1] = 0

for i in range(1, N):

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

    if i < N-1:

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



print((dp[N]))



dp = []
# iまでに要したminコスト
# dp[i] = dp[i-1]+abs(l[i]-l[i-1]) or dp[i-2]+abs(l[i+1]-l[i-1])
n = int(eval(input()))
l = list(map(int, input().split()))
dp.append(0)  # dp[0]
dp.append(abs(l[1] - l[0]))  # dp[1]
for i in range(2, n):
    new = min(dp[i - 1] + abs(l[i] - l[i - 1]), dp[i - 2] + abs(l[i] - l[i - 2]))
    dp.append(new)
ans = min(
    (dp[n - 2] + abs(l[n - 2] - l[n - 1])), (dp[n - 3] + abs(l[n - 3] - l[n - 1]))
)
print(ans)

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

-dp = [] -# iまでに要したminコスト -# dp[i] = dp[i-1]+abs(l[i]-l[i-1]) or dp[i-2]+abs(l[i+1]-l[i-1]) -n = int(eval(input())) -l = list(map(int, input().split())) -dp.append(0)  # dp[0] -dp.append(abs(l[1] - l[0]))  # dp[1] -for i in range(2, n): -    new = min(dp[i - 1] + abs(l[i] - l[i - 1]), dp[i - 2] + abs(l[i] - l[i - 2])) -    dp.append(new) -ans = min( -    (dp[n - 2] + abs(l[n - 2] - l[n - 1])), (dp[n - 3] + abs(l[n - 3] - l[n - 1])) -) -print(ans) +N = int(eval(input())) +h = [0] + list(map(int, input().split())) +dp = [10**100] * (N + 2) +dp[1] = 0 +for i in range(1, N): +    dp[i + 1] = min(dp[i + 1], dp[i] + abs(h[i + 1] - h[i])) +    if i < N - 1: +        dp[i + 2] = min(dp[i + 2], dp[i] + abs(h[i + 2] - h[i])) +print((dp[N]))