import sys

f = sys.stdin

n = int(f.readline())

h = list(map(int, f.readline().split()))

dp = [0]*n

dp[1] = abs(h[1] - h[0])

for i in range(2, n):

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

print((dp[-1]))

import sys

import io



f = sys.stdin.buffer

n = int(f.readline())

h = list(map(int, f.readline().split()))

p0, p1 = 0, abs(h[1] - h[0])

for i in range(2, n):

    p2 = min(p1 + abs(h[i] - h[i - 1]), p0 + abs(h[i] - h[i - 2]))

    p0, p1 = p1, p2

print(p1)

import sys

f = sys.stdin
n = int(f.readline())
h = list(map(int, f.readline().split()))
dp = [0] * n
dp[1] = abs(h[1] - h[0])
for i in range(2, n):
    dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2]))
print((dp[-1]))

import sys
import io

f = sys.stdin.buffer
n = int(f.readline())
h = list(map(int, f.readline().split()))
p0, p1 = 0, abs(h[1] - h[0])
for i in range(2, n):
    p2 = min(p1 + abs(h[i] - h[i - 1]), p0 + abs(h[i] - h[i - 2]))
    p0, p1 = p1, p2
print(p1)

+import io -f = sys.stdin +f = sys.stdin.buffer -dp = [0] * n -dp[1] = abs(h[1] - h[0]) +p0, p1 = 0, abs(h[1] - h[0]) -    dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2])) -print((dp[-1])) +    p2 = min(p1 + abs(h[i] - h[i - 1]), p0 + abs(h[i] - h[i - 2])) +    p0, p1 = p1, p2 +print(p1)