import numpy as np

N = int(eval(input()))

h = np.array(input().split(), dtype='int32')

dp = np.zeros(N, dtype='int32')



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

if N > 2:

    for i in range(2, N):

        dp[i] = np.min(dp[i-2:i] + np.abs(h[i]-h[i-2:i]))



print((dp[-1]))
# region header

import sys

import math

from bisect import bisect_left, bisect_right, insort_left, insort_right

from collections import defaultdict, deque, Counter

from copy import deepcopy

from fractions import gcd

from functools import lru_cache, reduce

from heapq import heappop, heappush

from itertools import accumulate, groupby, product, permutations, combinations, combinations_with_replacement

from math import ceil, floor, factorial, log, sqrt, sin, cos

from operator import itemgetter

from string import ascii_lowercase, ascii_uppercase, digits

sys.setrecursionlimit(10**6)

INF = float('inf')

MOD = 10 ** 9 + 7

def rs(): return sys.stdin.readline().rstrip()

def ri(): return int(rs())

def rf(): return float(rs())

def rs_(): return [_ for _ in rs().split()]

def ri_(): return [int(_) for _ in rs().split()]

def rf_(): return [float(_) for _ in rs().split()]

def divisors(n, sortresult=True):

    div = []

    for i in range(1, int(n**0.5)+1):

        if n % i == 0:

            div.append(i)

            if i != n // i:

                div.append(n//i)

    if sortresult:

        div.sort()

    return div

# endregion

N = ri()

h = ri_()

dp = [0] * N

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

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[N - 1]))
import numpy as np

N = int(eval(input()))
h = np.array(input().split(), dtype="int32")
dp = np.zeros(N, dtype="int32")
dp[1] = np.abs(h[1] - h[0])
if N > 2:
    for i in range(2, N):
        dp[i] = np.min(dp[i - 2 : i] + np.abs(h[i] - h[i - 2 : i]))
print((dp[-1]))

# region header
import sys
import math
from bisect import bisect_left, bisect_right, insort_left, insort_right
from collections import defaultdict, deque, Counter
from copy import deepcopy
from fractions import gcd
from functools import lru_cache, reduce
from heapq import heappop, heappush
from itertools import (
    accumulate,
    groupby,
    product,
    permutations,
    combinations,
    combinations_with_replacement,
)
from math import ceil, floor, factorial, log, sqrt, sin, cos
from operator import itemgetter
from string import ascii_lowercase, ascii_uppercase, digits

sys.setrecursionlimit(10**6)
INF = float("inf")
MOD = 10**9 + 7


def rs():
    return sys.stdin.readline().rstrip()


def ri():
    return int(rs())


def rf():
    return float(rs())


def rs_():
    return [_ for _ in rs().split()]


def ri_():
    return [int(_) for _ in rs().split()]


def rf_():
    return [float(_) for _ in rs().split()]


def divisors(n, sortresult=True):
    div = []
    for i in range(1, int(n**0.5) + 1):
        if n % i == 0:
            div.append(i)
            if i != n // i:
                div.append(n // i)
    if sortresult:
        div.sort()
    return div


# endregion
N = ri()
h = ri_()
dp = [0] * N
dp[1] = abs(h[0] - h[1])
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[N - 1]))

-import numpy as np +# region header +import sys +import math +from bisect import bisect_left, bisect_right, insort_left, insort_right +from collections import defaultdict, deque, Counter +from copy import deepcopy +from fractions import gcd +from functools import lru_cache, reduce +from heapq import heappop, heappush +from itertools import ( +    accumulate, +    groupby, +    product, +    permutations, +    combinations, +    combinations_with_replacement, +) +from math import ceil, floor, factorial, log, sqrt, sin, cos +from operator import itemgetter +from string import ascii_lowercase, ascii_uppercase, digits -N = int(eval(input())) -h = np.array(input().split(), dtype="int32") -dp = np.zeros(N, dtype="int32") -dp[1] = np.abs(h[1] - h[0]) -if N > 2: -    for i in range(2, N): -        dp[i] = np.min(dp[i - 2 : i] + np.abs(h[i] - h[i - 2 : i])) -print((dp[-1])) +sys.setrecursionlimit(10**6) +INF = float("inf") +MOD = 10**9 + 7 + + +def rs(): +    return sys.stdin.readline().rstrip() + + +def ri(): +    return int(rs()) + + +def rf(): +    return float(rs()) + + +def rs_(): +    return [_ for _ in rs().split()] + + +def ri_(): +    return [int(_) for _ in rs().split()] + + +def rf_(): +    return [float(_) for _ in rs().split()] + + +def divisors(n, sortresult=True): +    div = [] +    for i in range(1, int(n**0.5) + 1): +        if n % i == 0: +            div.append(i) +            if i != n // i: +                div.append(n // i) +    if sortresult: +        div.sort() +    return div + + +# endregion +N = ri() +h = ri_() +dp = [0] * N +dp[1] = abs(h[0] - h[1]) +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[N - 1]))