n=int(eval(input()))

hs=input().rstrip().split(" ")

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

costs[1]=abs(int(hs[1])-int(hs[0]))

for i in range(n-2):

    jump=costs[i]+abs(int(hs[i+2])-int(hs[i]))

    walk=costs[i+1]+abs(int(hs[i+2])-int(hs[i+1]))

    costs[i+2]=min(jump,walk)

print((costs[-1]))
import sys

input = sys.stdin.readline

sys.setrecursionlimit(10**7)

from collections import Counter, deque

from collections import defaultdict

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

from bisect import bisect_left,bisect_right

from heapq import heapify, heappop, heappush

from math import floor, ceil

from operator import itemgetter

def I(): return int(eval(input()))

def MI(): return list(map(int, input().split()))

def LI(): return list(map(int, input().split()))

def LI2(): return [int(eval(input())) for i in range(n)]

def MXI(): return [[LI()]for i in range(n)]

def printns(x): print(('\n'.join(x)))

def printni(x): print(('\n'.join(list(map(str,x)))))

inf = 10**17

mod = 10**9 + 7

#s=input().rstrip()



n=I()

h=LI()

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

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

for i in range(n-2):

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

#print(dp)

print((dp[-1]))
n = int(eval(input()))
hs = input().rstrip().split(" ")
costs = [0 for i in range(n)]
costs[1] = abs(int(hs[1]) - int(hs[0]))
for i in range(n - 2):
    jump = costs[i] + abs(int(hs[i + 2]) - int(hs[i]))
    walk = costs[i + 1] + abs(int(hs[i + 2]) - int(hs[i + 1]))
    costs[i + 2] = min(jump, walk)
print((costs[-1]))

import sys

input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left, bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil
from operator import itemgetter


def I():
    return int(eval(input()))


def MI():
    return list(map(int, input().split()))


def LI():
    return list(map(int, input().split()))


def LI2():
    return [int(eval(input())) for i in range(n)]


def MXI():
    return [[LI()] for i in range(n)]


def printns(x):
    print(("\n".join(x)))


def printni(x):
    print(("\n".join(list(map(str, x)))))


inf = 10**17
mod = 10**9 + 7
# s=input().rstrip()
n = I()
h = LI()
dp = [0 for i in range(n)]
dp[1] = abs(h[1] - h[0])
for i in range(n - 2):
    dp[i + 2] = min(dp[i] + abs(h[i + 2] - h[i]), dp[i + 1] + abs(h[i + 2] - h[i + 1]))
# print(dp)
print((dp[-1]))

-n = int(eval(input())) -hs = input().rstrip().split(" ") -costs = [0 for i in range(n)] -costs[1] = abs(int(hs[1]) - int(hs[0])) +import sys + +input = sys.stdin.readline +sys.setrecursionlimit(10**7) +from collections import Counter, deque +from collections import defaultdict +from itertools import combinations, permutations, accumulate, groupby, product +from bisect import bisect_left, bisect_right +from heapq import heapify, heappop, heappush +from math import floor, ceil +from operator import itemgetter + + +def I(): +    return int(eval(input())) + + +def MI(): +    return list(map(int, input().split())) + + +def LI(): +    return list(map(int, input().split())) + + +def LI2(): +    return [int(eval(input())) for i in range(n)] + + +def MXI(): +    return [[LI()] for i in range(n)] + + +def printns(x): +    print(("\n".join(x))) + + +def printni(x): +    print(("\n".join(list(map(str, x))))) + + +inf = 10**17 +mod = 10**9 + 7 +# s=input().rstrip() +n = I() +h = LI() +dp = [0 for i in range(n)] +dp[1] = abs(h[1] - h[0]) -    jump = costs[i] + abs(int(hs[i + 2]) - int(hs[i])) -    walk = costs[i + 1] + abs(int(hs[i + 2]) - int(hs[i + 1])) -    costs[i + 2] = min(jump, walk) -print((costs[-1])) +    dp[i + 2] = min(dp[i] + abs(h[i + 2] - h[i]), dp[i + 1] + abs(h[i + 2] - h[i + 1])) +# print(dp) +print((dp[-1]))