N = int(eval(input()))

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



INF = 10 ** 10



dp = [INF] * N

dp[0] = 0

dp[1] = abs(hs[1] - hs[0])



for i in range(1, N):

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

                dp[i - 2] + (abs(hs[i] - hs[i - 2])))



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

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



INF = 10 ** 10



dp = [INF] * N

dp[0] = 0

dp[1] = abs(hs[1] - hs[0])



for i in range(2, N):

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

                dp[i - 2] + (abs(hs[i] - hs[i - 2])))



print((dp[N - 1]))

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

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

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