import math

n = int(eval(input()))

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

'''

n-=1

inf = int(1e9+5)



dp = {}

def frog1(i):

    if i==n:

        return 0

    if i in dp:

        return dp[i]

    

    a = 0

    b = 0

    if i+1>n:

        a = inf

    else:

        a = frog1(i+1)+abs(h[i]-h[i+1])



    if i+2>n:

        b = inf

    else:

        b = frog1(i+2)+abs(h[i]-h[i+2])

    dp[i] = min(a,b)

    return dp[i]

'''

def solve(n,h):

    dp = [0]*n

    for i in reversed(list(range(0,n-1))):

        if i==n-1:

            dp[i] = 0

        else:

            if i==n-2:

                dp[i] = abs(h[n-1]-h[n-2])

                continue

            a = 0

            b = 0

            if i+1<=n-1:

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

            if i+2<=n-1:

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

            dp[i] = min(a,b)

    return dp[0]

print((solve(n,h)))

import math

from functools import lru_cache

def Frog1():

    n = int(eval(input()))

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

    @lru_cache(None)

    def Solve(i):

        if i==n-1:

            return 0

        if i==n-2:

            return abs(h[i]-h[i+1])

        return min(Solve(i+1)+abs(h[i]-h[i+1]),Solve(i+2)+abs(h[i]-h[i+2]))

    dp = [0]*n

    for i in reversed(list(range(n))):

        if i==n-1:

            dp[i] = 0

        elif i==n-2:

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

        else:

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

    print((dp[0]))

Frog1()





import math

n = int(eval(input()))
h = list(map(int, input().split(" ")))
"""
n-=1
inf = int(1e9+5)
dp = {}
def frog1(i):
    if i==n:
        return 0
    if i in dp:
        return dp[i]
    a = 0
    b = 0
    if i+1>n:
        a = inf
    else:
        a = frog1(i+1)+abs(h[i]-h[i+1])
    if i+2>n:
        b = inf
    else:
        b = frog1(i+2)+abs(h[i]-h[i+2])
    dp[i] = min(a,b)
    return dp[i]
"""


def solve(n, h):
    dp = [0] * n
    for i in reversed(list(range(0, n - 1))):
        if i == n - 1:
            dp[i] = 0
        else:
            if i == n - 2:
                dp[i] = abs(h[n - 1] - h[n - 2])
                continue
            a = 0
            b = 0
            if i + 1 <= n - 1:
                a = dp[i + 1] + abs(h[i] - h[i + 1])
            if i + 2 <= n - 1:
                b = dp[i + 2] + abs(h[i] - h[i + 2])
            dp[i] = min(a, b)
    return dp[0]


print((solve(n, h)))

import math
from functools import lru_cache


def Frog1():
    n = int(eval(input()))
    h = list(map(int, input().split(" ")))

    @lru_cache(None)
    def Solve(i):
        if i == n - 1:
            return 0
        if i == n - 2:
            return abs(h[i] - h[i + 1])
        return min(
            Solve(i + 1) + abs(h[i] - h[i + 1]), Solve(i + 2) + abs(h[i] - h[i + 2])
        )

    dp = [0] * n
    for i in reversed(list(range(n))):
        if i == n - 1:
            dp[i] = 0
        elif i == n - 2:
            dp[i] = abs(h[i] - h[i + 1])
        else:
            dp[i] = min(
                dp[i + 1] + abs(h[i] - h[i + 1]), dp[i + 2] + abs(h[i] - h[i + 2])
            )
    print((dp[0]))


Frog1()

- -n = int(eval(input())) -h = list(map(int, input().split(" "))) -""" -n-=1 -inf = int(1e9+5) -dp = {} -def frog1(i): -    if i==n: -        return 0 -    if i in dp: -        return dp[i] -    a = 0 -    b = 0 -    if i+1>n: -        a = inf -    else: -        a = frog1(i+1)+abs(h[i]-h[i+1]) -    if i+2>n: -        b = inf -    else: -        b = frog1(i+2)+abs(h[i]-h[i+2]) -    dp[i] = min(a,b) -    return dp[i] -""" +from functools import lru_cache -def solve(n, h): +def Frog1(): +    n = int(eval(input())) +    h = list(map(int, input().split(" "))) + +    @lru_cache(None) +    def Solve(i): +        if i == n - 1: +            return 0 +        if i == n - 2: +            return abs(h[i] - h[i + 1]) +        return min( +            Solve(i + 1) + abs(h[i] - h[i + 1]), Solve(i + 2) + abs(h[i] - h[i + 2]) +        ) + -    for i in reversed(list(range(0, n - 1))): +    for i in reversed(list(range(n))): +        elif i == n - 2: +            dp[i] = abs(h[i] - h[i + 1]) -            if i == n - 2: -                dp[i] = abs(h[n - 1] - h[n - 2]) -                continue -            a = 0 -            b = 0 -            if i + 1 <= n - 1: -                a = dp[i + 1] + abs(h[i] - h[i + 1]) -            if i + 2 <= n - 1: -                b = dp[i + 2] + abs(h[i] - h[i + 2]) -            dp[i] = min(a, b) -    return dp[0] +            dp[i] = min( +                dp[i + 1] + abs(h[i] - h[i + 1]), dp[i + 2] + abs(h[i] - h[i + 2]) +            ) +    print((dp[0])) -print((solve(n, h))) +Frog1()