N = int(eval(input()))

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



min_jump = [1000000000000 for i in range(N)]

min_jump[0] = 0

for i in range(1,N):

    min_jump[i] = min(abs(stones[i] - stones[i-1]) + min_jump[i-1],abs(stones[i] - stones[i-2]) + min_jump[i-2])

print((min_jump[N-1]))

N = int(eval(input()))

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



dp = [0,abs(X[1] - X[0])]

for x in range(2,N):

  dp.append(min(dp[x-1] + abs(X[x-1]-X[x]),

                dp[x-2] + abs(X[x-2]-X[x])

               )

           )

print((dp[N-1]))
N = int(eval(input()))
stones = list(map(int, input().split()))
min_jump = [1000000000000 for i in range(N)]
min_jump[0] = 0
for i in range(1, N):
    min_jump[i] = min(
        abs(stones[i] - stones[i - 1]) + min_jump[i - 1],
        abs(stones[i] - stones[i - 2]) + min_jump[i - 2],
    )
print((min_jump[N - 1]))

N = int(eval(input()))
X = list(map(int, input().split()))
dp = [0, abs(X[1] - X[0])]
for x in range(2, N):
    dp.append(min(dp[x - 1] + abs(X[x - 1] - X[x]), dp[x - 2] + abs(X[x - 2] - X[x])))
print((dp[N - 1]))

-stones = list(map(int, input().split())) -min_jump = [1000000000000 for i in range(N)] -min_jump[0] = 0 -for i in range(1, N): -    min_jump[i] = min( -        abs(stones[i] - stones[i - 1]) + min_jump[i - 1], -        abs(stones[i] - stones[i - 2]) + min_jump[i - 2], -    ) -print((min_jump[N - 1])) +X = list(map(int, input().split())) +dp = [0, abs(X[1] - X[0])] +for x in range(2, N): +    dp.append(min(dp[x - 1] + abs(X[x - 1] - X[x]), dp[x - 2] + abs(X[x - 2] - X[x]))) +print((dp[N - 1]))