N = int(eval(input()))

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

dp = [float('inf') for i in range(N)]

dp[0] = 0

for i in range(1, N):

    if (dp[i] > dp[i-1] + abs(h[i] - h[i-1])):

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

    if i > 1:

        if (dp[i] > dp[i-2] + abs(h[i] - h[i-2])):

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

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

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

cost = [0 for _ in range(len(h))]

for i in range(1, len(h)):

    if i == 1:

        cost[i] = abs(h[i] - h[i-1])

        continue

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

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

N = int(eval(input()))
h = list(map(int, input().split()))
cost = [0 for _ in range(len(h))]
for i in range(1, len(h)):
    if i == 1:
        cost[i] = abs(h[i] - h[i - 1])
        continue
    cost[i] = min(
        cost[i - 1] + abs(h[i] - h[i - 1]), cost[i - 2] + abs(h[i] - h[i - 2])
    )
print((cost[-1]))

-dp = [float("inf") for i in range(N)] -dp[0] = 0 -for i in range(1, N): -    if dp[i] > dp[i - 1] + abs(h[i] - h[i - 1]): -        dp[i] = dp[i - 1] + abs(h[i] - h[i - 1]) -    if i > 1: -        if dp[i] > dp[i - 2] + abs(h[i] - h[i - 2]): -            dp[i] = dp[i - 2] + abs(h[i] - h[i - 2]) -print((dp[-1])) +cost = [0 for _ in range(len(h))] +for i in range(1, len(h)): +    if i == 1: +        cost[i] = abs(h[i] - h[i - 1]) +        continue +    cost[i] = min( +        cost[i - 1] + abs(h[i] - h[i - 1]), cost[i - 2] + abs(h[i] - h[i - 2]) +    ) +print((cost[-1]))