N = int(eval(input()))

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

DP = [10000] * N

DP[0] = 0

DP[1] = max(h[0]-h[1],h[1]-h[0])

for i in range(2,N):

  DP[i] = min(DP[i-2] + max(h[i]-h[i-2],h[i-2]-h[i]),DP[i-1] + max(h[i]-h[i-1],h[i-1]-h[i]))

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

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

DP=[0]*(N+1)

DP[2] = DP[1] + abs(h[0]-h[1])

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

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

print((DP[N]))
N = int(eval(input()))
h = [int(x) for x in input().split()]
DP = [10000] * N
DP[0] = 0
DP[1] = max(h[0] - h[1], h[1] - h[0])
for i in range(2, N):
    DP[i] = min(
        DP[i - 2] + max(h[i] - h[i - 2], h[i - 2] - h[i]),
        DP[i - 1] + max(h[i] - h[i - 1], h[i - 1] - h[i]),
    )
print((DP[N - 1]))

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

-DP = [10000] * N -DP[0] = 0 -DP[1] = max(h[0] - h[1], h[1] - h[0]) -for i in range(2, N): +DP = [0] * (N + 1) +DP[2] = DP[1] + abs(h[0] - h[1]) +for i in range(3, N + 1): -        DP[i - 2] + max(h[i] - h[i - 2], h[i - 2] - h[i]), -        DP[i - 1] + max(h[i] - h[i - 1], h[i - 1] - h[i]), +        DP[i - 2] + abs(h[i - 3] - h[i - 1]), DP[i - 1] + abs(h[i - 2] - h[i - 1]) -print((DP[N - 1])) +print((DP[N]))