n = int(eval(input()))

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

dp = [0 for i in range(n)]

for i in range(n):

    if i==0:

        dp[i] = 0

    elif i==1:

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

    else:

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



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

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

H = [0] + H

dp = [0] * (N+1)

for i in range(2,N+1):

    if i-2>=1:

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

    else:

        dp[i] = dp[i] + abs(H[i]-H[i-1])

res = dp[N]

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

N = int(eval(input()))
H = list(map(int, input().split()))
H = [0] + H
dp = [0] * (N + 1)
for i in range(2, N + 1):
    if i - 2 >= 1:
        dp[i] = min(dp[i - 1] + abs(H[i] - H[i - 1]), dp[i - 2] + abs(H[i] - H[i - 2]))
    else:
        dp[i] = dp[i] + abs(H[i] - H[i - 1])
res = dp[N]
print(res)

-n = int(eval(input())) -h = [int(i) for i in input().split()] -dp = [0 for i in range(n)] -for i in range(n): -    if i == 0: -        dp[i] = 0 -    elif i == 1: -        dp[i] = abs(h[i] - h[i - 1]) +N = int(eval(input())) +H = list(map(int, input().split())) +H = [0] + H +dp = [0] * (N + 1) +for i in range(2, N + 1): +    if i - 2 >= 1: +        dp[i] = min(dp[i - 1] + abs(H[i] - H[i - 1]), dp[i - 2] + abs(H[i] - H[i - 2])) -        dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2])) -print((dp[n - 1])) +        dp[i] = dp[i] + abs(H[i] - H[i - 1]) +res = dp[N] +print(res)