import math



N = int(eval(input()))

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

dp = [float('INF')] * N



def chmin(a, b):

    if a >= b:

        return b

    else:

        return a



#初期値

dp[0] = 0



#Loop

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]))

print((dp[-1]))
import math



N = int(eval(input()))

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

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



def chmin(a, b):

    if a >= b:

        return b

    else:

        return a



dp[0] = 0 #初期値 = 0

for i in range(N-1):

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

    if i < N-2:

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

print((dp[N-1]))
import math

N = int(eval(input()))
h = list(map(int, input().split()))
dp = [float("INF")] * N


def chmin(a, b):
    if a >= b:
        return b
    else:
        return a


# 初期値
dp[0] = 0
# Loop
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]))
print((dp[-1]))

import math

N = int(eval(input()))
h = list(map(int, input().split()))
dp = [float("INF")] * (10**5 + 10)


def chmin(a, b):
    if a >= b:
        return b
    else:
        return a


dp[0] = 0  # 初期値 = 0
for i in range(N - 1):
    dp[i + 1] = chmin(dp[i + 1], dp[i] + abs(h[i + 1] - h[i]))
    if i < N - 2:
        dp[i + 2] = chmin(dp[i + 2], dp[i] + abs(h[i + 2] - h[i]))
print((dp[N - 1]))

-dp = [float("INF")] * N +dp = [float("INF")] * (10**5 + 10) -# 初期値 -dp[0] = 0 -# Loop -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])) -print((dp[-1])) +dp[0] = 0  # 初期値 = 0 +for i in range(N - 1): +    dp[i + 1] = chmin(dp[i + 1], dp[i] + abs(h[i + 1] - h[i])) +    if i < N - 2: +        dp[i + 2] = chmin(dp[i + 2], dp[i] + abs(h[i + 2] - h[i])) +print((dp[N - 1]))