n = int(eval(input()))

dp = [10 ** 9 for _ in range(n + 2)] # ちょっと大きめに

dp[0] = 0



h = [int(x) for x in input().split()]



for i in range(1, n):

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

  dp[i] = min(dp[i], total_cost)

  if i > 1:

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

    dp[i] = min(dp[i], total_cost)

  

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

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



dp = [10 ** 9 for _ in range(n+1)]

# スタート位置

dp[0] = 0



for i in range(n):

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

    if i > 1:

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



print((dp[n-1]))
n = int(eval(input()))
dp = [10**9 for _ in range(n + 2)]  # ちょっと大きめに
dp[0] = 0
h = [int(x) for x in input().split()]
for i in range(1, n):
    total_cost = dp[i - 1] + abs(h[i] - h[i - 1])
    dp[i] = min(dp[i], total_cost)
    if i > 1:
        total_cost = dp[i - 2] + abs(h[i] - h[i - 2])
        dp[i] = min(dp[i], total_cost)
print((dp[n - 1]))

n = int(eval(input()))
h = list(map(int, input().split()))
dp = [10**9 for _ in range(n + 1)]
# スタート位置
dp[0] = 0
for i in range(n):
    dp[i] = min(dp[i], dp[i - 1] + abs(h[i] - h[i - 1]))
    if i > 1:
        dp[i] = min(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]))
print((dp[n - 1]))

-dp = [10**9 for _ in range(n + 2)]  # ちょっと大きめに +h = list(map(int, input().split())) +dp = [10**9 for _ in range(n + 1)] +# スタート位置 -h = [int(x) for x in input().split()] -for i in range(1, n): -    total_cost = dp[i - 1] + abs(h[i] - h[i - 1]) -    dp[i] = min(dp[i], total_cost) +for i in range(n): +    dp[i] = min(dp[i], dp[i - 1] + abs(h[i] - h[i - 1])) -        total_cost = dp[i - 2] + abs(h[i] - h[i - 2]) -        dp[i] = min(dp[i], total_cost) +        dp[i] = min(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]))