N = int(eval(input()))

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

dp = [10 ** 10] * N

# dp[n]はあとnのところからのN-1に行くのに支払うコストの最小値

dp[0] = 0

dp[1] = abs(h[N-1]-h[N-2])

for n in range(0, N-2):

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

                  dp[n]+abs(h[(N-1)-(n+2)]-h[(N-1)-n]))

print((dp[N-1]))

N = int(eval(input()))

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

a, b = 0, abs(h[0] - h[1])

for n in range(N - 2):

    a, b = b, min(a + abs(h[n] - h[n + 2]), b + abs(h[n + 1] - h[n + 2]))

print(b)

N = int(eval(input()))
h = list(map(int, input().split()))
dp = [10**10] * N
# dp[n]はあとnのところからのN-1に行くのに支払うコストの最小値
dp[0] = 0
dp[1] = abs(h[N - 1] - h[N - 2])
for n in range(0, N - 2):
    dp[n + 2] = min(
        dp[n + 1] + abs(h[(N - 1) - (n + 2)] - h[(N - 1) - (n + 1)]),
        dp[n] + abs(h[(N - 1) - (n + 2)] - h[(N - 1) - n]),
    )
print((dp[N - 1]))

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

-dp = [10**10] * N -# dp[n]はあとnのところからのN-1に行くのに支払うコストの最小値 -dp[0] = 0 -dp[1] = abs(h[N - 1] - h[N - 2]) -for n in range(0, N - 2): -    dp[n + 2] = min( -        dp[n + 1] + abs(h[(N - 1) - (n + 2)] - h[(N - 1) - (n + 1)]), -        dp[n] + abs(h[(N - 1) - (n + 2)] - h[(N - 1) - n]), -    ) -print((dp[N - 1])) +a, b = 0, abs(h[0] - h[1]) +for n in range(N - 2): +    a, b = b, min(a + abs(h[n] - h[n + 2]), b + abs(h[n + 1] - h[n + 2])) +print(b)