def chmin(a, b):

    if a > b:

        return b

    else:

        return a



# input

N = int(eval(input()))

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



# dp table

dp = [float('inf')]*(10**5 + 10)



# 初期条件

dp[0] = 0



for i in range(1,N):

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

    if i > 1:

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



# ans

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

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



dp = [float('inf')]*(10**5 + 10)

dp[0] = 0



for i in range(1,N):

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



print((dp[N-1]))
def chmin(a, b):
    if a > b:
        return b
    else:
        return a


# input
N = int(eval(input()))
h = list(map(int, input().split()))
# dp table
dp = [float("inf")] * (10**5 + 10)
# 初期条件
dp[0] = 0
for i in range(1, N):
    dp[i] = chmin(dp[i], dp[i - 1] + abs(h[i] - h[i - 1]))
    if i > 1:
        dp[i] = chmin(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]))
# ans
print((dp[N - 1]))

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

-def chmin(a, b): -    if a > b: -        return b -    else: -        return a - - -# input -# dp table -# 初期条件 -    dp[i] = chmin(dp[i], dp[i - 1] + abs(h[i] - h[i - 1])) -    if i > 1: -        dp[i] = chmin(dp[i], dp[i - 2] + abs(h[i] - h[i - 2])) -# ans +    dp[i] = min( +        dp[i], dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2]) +    )