N = int(eval(input()))

*T, = list(map(int, input().split()))



INF = float("inf")  # pythonでの無限大の作り方

DP = [INF for i in range(N)]



def chmin(a, b):

     if a > b:

          return b

     return a



DP[0] = 0

for i in range(1, N):

     DP[i] = chmin(DP[i], DP[i-1] + abs(T[i-1] - T[i]))

     DP[i] = chmin(DP[i], DP[i-2] + abs(T[i-2] - T[i]))



print((int(DP[-1])))
"""

dp[i] := 足場iまでにかかるコストの最小値

"""

N = int(eval(input()))

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

dp = [0 for _ in range(N)]

dp[1] = abs(h[0] - h[1])  # initialize dp



for i in range(2, N):

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

    case2 = dp[i-2] + abs(h[i-2] - h[i])

    dp[i] = min(case1, case2)



print((dp[-1]))
N = int(eval(input()))
(*T,) = list(map(int, input().split()))
INF = float("inf")  # pythonでの無限大の作り方
DP = [INF for i in range(N)]


def chmin(a, b):
    if a > b:
        return b
    return a


DP[0] = 0
for i in range(1, N):
    DP[i] = chmin(DP[i], DP[i - 1] + abs(T[i - 1] - T[i]))
    DP[i] = chmin(DP[i], DP[i - 2] + abs(T[i - 2] - T[i]))
print((int(DP[-1])))

"""
dp[i] := 足場iまでにかかるコストの最小値
"""
N = int(eval(input()))
(*h,) = list(map(int, input().split()))
dp = [0 for _ in range(N)]
dp[1] = abs(h[0] - h[1])  # initialize dp
for i in range(2, N):
    case1 = dp[i - 1] + abs(h[i - 1] - h[i])
    case2 = dp[i - 2] + abs(h[i - 2] - h[i])
    dp[i] = min(case1, case2)
print((dp[-1]))

+""" +dp[i] := 足場iまでにかかるコストの最小値 +""" -(*T,) = list(map(int, input().split())) -INF = float("inf")  # pythonでの無限大の作り方 -DP = [INF for i in range(N)] - - -def chmin(a, b): -    if a > b: -        return b -    return a - - -DP[0] = 0 -for i in range(1, N): -    DP[i] = chmin(DP[i], DP[i - 1] + abs(T[i - 1] - T[i])) -    DP[i] = chmin(DP[i], DP[i - 2] + abs(T[i - 2] - T[i])) -print((int(DP[-1]))) +(*h,) = list(map(int, input().split())) +dp = [0 for _ in range(N)] +dp[1] = abs(h[0] - h[1])  # initialize dp +for i in range(2, N): +    case1 = dp[i - 1] + abs(h[i - 1] - h[i]) +    case2 = dp[i - 2] + abs(h[i - 2] - h[i]) +    dp[i] = min(case1, case2) +print((dp[-1]))