n = int(eval(input()))

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

INF = float('inf')

dp = [INF] * (1 + 10 ** 5)

dp[0] = 0

for i in range(n):

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

    if i < 2:

        continue

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

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

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

INF = float('inf')

dp = [INF] * N

dp[0] = 0

for i in range(1, N):

    if i == 1:

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

    else:

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

# print(dp)

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

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

-n = int(eval(input())) +N = int(eval(input())) -dp = [INF] * (1 + 10**5) +dp = [INF] * N -for i in range(n): -    dp[i] = min(dp[i], dp[i - 1] + abs(h[i] - h[i - 1])) -    if i < 2: -        continue -    dp[i] = min(dp[i], dp[i - 2] + abs(h[i] - h[i - 2])) -print((dp[n - 1])) +for i in range(1, N): +    if i == 1: +        dp[i] = min(dp[i], dp[i - 1] + abs(h[i] - h[i - 1])) +    else: +        dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2])) +# print(dp) +print((dp[N - 1]))