# python template for atcoder1

import sys

sys.setrecursionlimit(10**9)

input = sys.stdin.readline



N = int(eval(input()))

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

d = [float('inf')]*N



if N <= 3:

    print((abs(H[0]-H[-1])))

else:

    d[0] = 0

    d[1] = abs(H[1]-H[0])

    d[2] = abs(H[2]-H[0])

    for i in range(3, N):

        d[i] = min(d[i-1]+abs(H[i]-H[i-1]), d[i-2]+abs(H[i]-H[i-2]))

    print((d[-1]))

# python template for atcoder1

import sys

sys.setrecursionlimit(10**9)

input = sys.stdin.readline



N = int(eval(input()))

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

d = [float('inf')]*N





def solve():

    if N <= 3:

        print((abs(H[0]-H[-1])))

    else:

        d[0] = 0

        d[1] = abs(H[1]-H[0])

        d[2] = abs(H[2]-H[0])

        for i in range(3, N):

            d[i] = min(d[i-1]+abs(H[i]-H[i-1]), d[i-2]+abs(H[i]-H[i-2]))

        print((d[-1]))





def solve2():

    a = 0

    b = abs(H[1]-H[0])

    for i in range(2, N):

        a, b = b, min(abs(H[i]-H[i-1])+b, abs(H[i]-H[i-2])+a)

    print(b)





solve2()

# python template for atcoder1
import sys

sys.setrecursionlimit(10**9)
input = sys.stdin.readline
N = int(eval(input()))
H = list(map(int, input().split()))
d = [float("inf")] * N
if N <= 3:
    print((abs(H[0] - H[-1])))
else:
    d[0] = 0
    d[1] = abs(H[1] - H[0])
    d[2] = abs(H[2] - H[0])
    for i in range(3, N):
        d[i] = min(d[i - 1] + abs(H[i] - H[i - 1]), d[i - 2] + abs(H[i] - H[i - 2]))
    print((d[-1]))

# python template for atcoder1
import sys

sys.setrecursionlimit(10**9)
input = sys.stdin.readline
N = int(eval(input()))
H = list(map(int, input().split()))
d = [float("inf")] * N


def solve():
    if N <= 3:
        print((abs(H[0] - H[-1])))
    else:
        d[0] = 0
        d[1] = abs(H[1] - H[0])
        d[2] = abs(H[2] - H[0])
        for i in range(3, N):
            d[i] = min(d[i - 1] + abs(H[i] - H[i - 1]), d[i - 2] + abs(H[i] - H[i - 2]))
        print((d[-1]))


def solve2():
    a = 0
    b = abs(H[1] - H[0])
    for i in range(2, N):
        a, b = b, min(abs(H[i] - H[i - 1]) + b, abs(H[i] - H[i - 2]) + a)
    print(b)


solve2()

-if N <= 3: -    print((abs(H[0] - H[-1]))) -else: -    d[0] = 0 -    d[1] = abs(H[1] - H[0]) -    d[2] = abs(H[2] - H[0]) -    for i in range(3, N): -        d[i] = min(d[i - 1] + abs(H[i] - H[i - 1]), d[i - 2] + abs(H[i] - H[i - 2])) -    print((d[-1])) + + +def solve(): +    if N <= 3: +        print((abs(H[0] - H[-1]))) +    else: +        d[0] = 0 +        d[1] = abs(H[1] - H[0]) +        d[2] = abs(H[2] - H[0]) +        for i in range(3, N): +            d[i] = min(d[i - 1] + abs(H[i] - H[i - 1]), d[i - 2] + abs(H[i] - H[i - 2])) +        print((d[-1])) + + +def solve2(): +    a = 0 +    b = abs(H[1] - H[0]) +    for i in range(2, N): +        a, b = b, min(abs(H[i] - H[i - 1]) + b, abs(H[i] - H[i - 2]) + a) +    print(b) + + +solve2()