import itertools,sys

def I(): return int(sys.stdin.readline().rstrip())

def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))

N = I()

h = [None]+LI()

dp = [float('INF')]*(N+1) #1_indexed

dp[1] = 0

for i,j in itertools.product(list(range(1,N+1)),[1,2]):

    if i+j>=N+1:

        continue

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

print((dp[-1]))

import itertools,sys

def I(): return int(sys.stdin.readline().rstrip())

def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))

N = I()

h = LI()

dp = [float('INF')]*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[-1]))
import itertools, sys


def I():
    return int(sys.stdin.readline().rstrip())


def LI():
    return list(map(int, sys.stdin.readline().rstrip().split()))


N = I()
h = [None] + LI()
dp = [float("INF")] * (N + 1)  # 1_indexed
dp[1] = 0
for i, j in itertools.product(list(range(1, N + 1)), [1, 2]):
    if i + j >= N + 1:
        continue
    dp[i + j] = min(dp[i + j], dp[i] + abs(h[i + j] - h[i]))
print((dp[-1]))

import itertools, sys


def I():
    return int(sys.stdin.readline().rstrip())


def LI():
    return list(map(int, sys.stdin.readline().rstrip().split()))


N = I()
h = LI()
dp = [float("INF")] * 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[-1]))

-h = [None] + LI() -dp = [float("INF")] * (N + 1)  # 1_indexed -dp[1] = 0 -for i, j in itertools.product(list(range(1, N + 1)), [1, 2]): -    if i + j >= N + 1: -        continue -    dp[i + j] = min(dp[i + j], dp[i] + abs(h[i + j] - h[i])) +h = LI() +dp = [float("INF")] * 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]))