import math

import operator as op

from functools import reduce

from fractions import Fraction as frac



def ncr(n, r):

    r = min(r, n-r)

    numer = reduce(op.mul, list(range(n, n-r, -1)), 1)

    denom = reduce(op.mul, list(range(1, r+1)), 1)

    return numer / denom

"""

int(input())

map(int,input().split())

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

"""

# t=int(input())

t=1

for term in range(t):

    n=int(eval(input()))

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

    B=[0 for i in range(n)]

    B[1]=abs(A[0]-A[1])

    for i in range(2,n):

        B[i]=min(B[i-2]+abs(A[i-2]-A[i]),B[i-1]+abs(A[i-1]-A[i]))

    print((B[n-1]))
import sys

from functools import lru_cache, cmp_to_key

from heapq import merge, heapify, heappop, heappush

from math import *

from collections import defaultdict as dd, deque, Counter as C

from itertools import combinations as comb, permutations as perm

from bisect import bisect_left as bl, bisect_right as br, bisect

from time import perf_counter

from fractions import Fraction

import copy

import time

# import numpy as np

starttime = time.time()

# import numpy as np

mod = int(pow(10, 9) + 7)

mod2 = 998244353

def data(): return sys.stdin.readline().strip()

def out(*var, end="\n"): sys.stdout.write(' '.join(map(str, var))+end)

def L(): return list(sp())

def sl(): return list(ssp())

def sp(): return list(map(int, data().split()))

def ssp(): return list(map(str, data().split()))

def l1d(n, val=0): return [val for i in range(n)]

def l2d(n, m, val=0): return [l1d(n, val) for j in range(m)]



try:

    # sys.setrecursionlimit(int(pow(10,6)))

    sys.stdin = open("input.txt", "r")

    # sys.stdout = open("../output.txt", "w")

except:

    pass



n=L()[0]

H=L()

dp=[0 for i in range(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]))







endtime = time.time()

# print(f"Runtime of the program is {endtime - starttime}")



import math
import operator as op
from functools import reduce
from fractions import Fraction as frac


def ncr(n, r):
    r = min(r, n - r)
    numer = reduce(op.mul, list(range(n, n - r, -1)), 1)
    denom = reduce(op.mul, list(range(1, r + 1)), 1)
    return numer / denom


"""
int(input())
map(int,input().split())
list(map(int,input().split()))
"""
# t=int(input())
t = 1
for term in range(t):
    n = int(eval(input()))
    A = list(map(int, input().split()))
    B = [0 for i in range(n)]
    B[1] = abs(A[0] - A[1])
    for i in range(2, n):
        B[i] = min(B[i - 2] + abs(A[i - 2] - A[i]), B[i - 1] + abs(A[i - 1] - A[i]))
    print((B[n - 1]))

import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from math import *
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction
import copy
import time

# import numpy as np
starttime = time.time()
# import numpy as np
mod = int(pow(10, 9) + 7)
mod2 = 998244353


def data():
    return sys.stdin.readline().strip()


def out(*var, end="\n"):
    sys.stdout.write(" ".join(map(str, var)) + end)


def L():
    return list(sp())


def sl():
    return list(ssp())


def sp():
    return list(map(int, data().split()))


def ssp():
    return list(map(str, data().split()))


def l1d(n, val=0):
    return [val for i in range(n)]


def l2d(n, m, val=0):
    return [l1d(n, val) for j in range(m)]


try:
    # sys.setrecursionlimit(int(pow(10,6)))
    sys.stdin = open("input.txt", "r")
    # sys.stdout = open("../output.txt", "w")
except:
    pass
n = L()[0]
H = L()
dp = [0 for i in range(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]))
endtime = time.time()
# print(f"Runtime of the program is {endtime - starttime}")

-import math -import operator as op -from functools import reduce -from fractions import Fraction as frac +import sys +from functools import lru_cache, cmp_to_key +from heapq import merge, heapify, heappop, heappush +from math import * +from collections import defaultdict as dd, deque, Counter as C +from itertools import combinations as comb, permutations as perm +from bisect import bisect_left as bl, bisect_right as br, bisect +from time import perf_counter +from fractions import Fraction +import copy +import time + +# import numpy as np +starttime = time.time() +# import numpy as np +mod = int(pow(10, 9) + 7) +mod2 = 998244353 -def ncr(n, r): -    r = min(r, n - r) -    numer = reduce(op.mul, list(range(n, n - r, -1)), 1) -    denom = reduce(op.mul, list(range(1, r + 1)), 1) -    return numer / denom +def data(): +    return sys.stdin.readline().strip() -""" -int(input()) -map(int,input().split()) -list(map(int,input().split())) -""" -# t=int(input()) -t = 1 -for term in range(t): -    n = int(eval(input())) -    A = list(map(int, input().split())) -    B = [0 for i in range(n)] -    B[1] = abs(A[0] - A[1]) -    for i in range(2, n): -        B[i] = min(B[i - 2] + abs(A[i - 2] - A[i]), B[i - 1] + abs(A[i - 1] - A[i])) -    print((B[n - 1])) +def out(*var, end="\n"): +    sys.stdout.write(" ".join(map(str, var)) + end) + + +def L(): +    return list(sp()) + + +def sl(): +    return list(ssp()) + + +def sp(): +    return list(map(int, data().split())) + + +def ssp(): +    return list(map(str, data().split())) + + +def l1d(n, val=0): +    return [val for i in range(n)] + + +def l2d(n, m, val=0): +    return [l1d(n, val) for j in range(m)] + + +try: +    # sys.setrecursionlimit(int(pow(10,6))) +    sys.stdin = open("input.txt", "r") +    # sys.stdout = open("../output.txt", "w") +except: +    pass +n = L()[0] +H = L() +dp = [0 for i in range(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])) +endtime = time.time() +# print(f"Runtime of the program is {endtime - starttime}")