import sys

sys.setrecursionlimit(10**6)



N = int(eval(input()))

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

dp = [-1] * (N+1)



def rec(i):

    if i == 0:

        return 0

    if dp[i] != -1:

        return dp[i]

    dp[i] = 2**60 # 十分大きな値

    if i - 1 >= 0:

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

    if i - 2 >= 0:

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

    return dp[i]



print((rec(N-1)))

N = int(eval(input()))

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

dp = [2**60] * N

dp[0] = 0

for i in range(N):

    if i - 1 >= 0:

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

    if i - 2 >= 0:

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

print((dp[N-1]))

import sys

sys.setrecursionlimit(10**6)
N = int(eval(input()))
h = list(map(int, input().split()))
dp = [-1] * (N + 1)


def rec(i):
    if i == 0:
        return 0
    if dp[i] != -1:
        return dp[i]
    dp[i] = 2**60  # 十分大きな値
    if i - 1 >= 0:
        dp[i] = min(dp[i], rec(i - 1) + abs(h[i - 1] - h[i]))
    if i - 2 >= 0:
        dp[i] = min(dp[i], rec(i - 2) + abs(h[i - 2] - h[i]))
    return dp[i]


print((rec(N - 1)))

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

-import sys - -sys.setrecursionlimit(10**6) -dp = [-1] * (N + 1) - - -def rec(i): -    if i == 0: -        return 0 -    if dp[i] != -1: -        return dp[i] -    dp[i] = 2**60  # 十分大きな値 +dp = [2**60] * N +dp[0] = 0 +for i in range(N): -        dp[i] = min(dp[i], rec(i - 1) + abs(h[i - 1] - h[i])) +        dp[i] = min(dp[i], dp[i - 1] + abs(h[i] - h[i - 1])) -        dp[i] = min(dp[i], rec(i - 2) + abs(h[i - 2] - h[i])) -    return dp[i] - - -print((rec(N - 1))) +        dp[i] = min(dp[i], dp[i - 2] + abs(h[i] - h[i - 2])) +print((dp[N - 1]))