

N = int(eval(input()))

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

inf = 10**9+7

dp = [inf] * (N+10)

dp[0] = 0

import numpy as np

for i,h in enumerate(H[:N-1]):

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

    if i<N-2: dp[i+2] = min(dp[i+2],dp[i] + np.abs(h-H[i+2]))

    

print((dp[N-1]))


import sys

sys.setrecursionlimit(10**8)

input = sys.stdin.readline



N = int(eval(input()))

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



INF = 10**20

dp = [INF]*(N+10)

dp[0] = 0

def distance(x,y):

    return abs(h[x]-h[y])

dp[1] = distance(0,1)

for i in range(2,N):

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

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

print((dp[N-1]))

    
N = int(eval(input()))
H = list(map(int, input().split()))
inf = 10**9 + 7
dp = [inf] * (N + 10)
dp[0] = 0
import numpy as np

for i, h in enumerate(H[: N - 1]):
    dp[i + 1] = min(dp[i + 1], dp[i] + np.abs(h - H[i + 1]))
    if i < N - 2:
        dp[i + 2] = min(dp[i + 2], dp[i] + np.abs(h - H[i + 2]))
print((dp[N - 1]))

import sys

sys.setrecursionlimit(10**8)
input = sys.stdin.readline
N = int(eval(input()))
h = list(map(int, input().split()))
INF = 10**20
dp = [INF] * (N + 10)
dp[0] = 0


def distance(x, y):
    return abs(h[x] - h[y])


dp[1] = distance(0, 1)
for i in range(2, N):
    dp[i] = min(dp[i], dp[i - 1] + distance(i - 1, i))
    dp[i] = min(dp[i], dp[i - 2] + distance(i - 2, i))
print((dp[N - 1]))

+import sys + +sys.setrecursionlimit(10**8) +input = sys.stdin.readline -H = list(map(int, input().split())) -inf = 10**9 + 7 -dp = [inf] * (N + 10) +h = list(map(int, input().split())) +INF = 10**20 +dp = [INF] * (N + 10) -import numpy as np -for i, h in enumerate(H[: N - 1]): -    dp[i + 1] = min(dp[i + 1], dp[i] + np.abs(h - H[i + 1])) -    if i < N - 2: -        dp[i + 2] = min(dp[i + 2], dp[i] + np.abs(h - H[i + 2])) + +def distance(x, y): +    return abs(h[x] - h[y]) + + +dp[1] = distance(0, 1) +for i in range(2, N): +    dp[i] = min(dp[i], dp[i - 1] + distance(i - 1, i)) +    dp[i] = min(dp[i], dp[i - 2] + distance(i - 2, i))