class struct:

  def __init__(self,a,b):

    self.a=a

    self.b=b



n=int(eval(input()))

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



l2=[struct(0,0) for _ in range(n)]

l2[0].a=l[0]

l2[1].a=l[1]

l2[1].b=abs(l[0]-l[1])



i=2

for x in l[2:]:

  l2[i].a=x

  l2[i].b=min(abs(l2[i-2].a-x)+l2[i-2].b,

    abs(l2[i-1].a-x)+l2[i-1].b)

  i+=1



print((l2[-1].b))
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time



sys.setrecursionlimit(10**7)

inf=10**20

mod=10**9+7



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

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

def LS(): return input().split()

def S(): return eval(input())



def main():

  n=I()

  l=LI()



  dp=[0]*100010



  dp[1]=0

  dp[2]=abs(l[0]-l[1])

  for i in range(2,n):

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



  return dp[n]



print((main()))

class struct:
    def __init__(self, a, b):
        self.a = a
        self.b = b


n = int(eval(input()))
l = list(map(int, input().split()))
l2 = [struct(0, 0) for _ in range(n)]
l2[0].a = l[0]
l2[1].a = l[1]
l2[1].b = abs(l[0] - l[1])
i = 2
for x in l[2:]:
    l2[i].a = x
    l2[i].b = min(
        abs(l2[i - 2].a - x) + l2[i - 2].b, abs(l2[i - 1].a - x) + l2[i - 1].b
    )
    i += 1
print((l2[-1].b))

import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, random, time

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7


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


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


def LS():
    return input().split()


def S():
    return eval(input())


def main():
    n = I()
    l = LI()
    dp = [0] * 100010
    dp[1] = 0
    dp[2] = abs(l[0] - l[1])
    for i in range(2, n):
        dp[i + 1] = min(dp[i] + abs(l[i] - l[i - 1]), dp[i - 1] + abs(l[i] - l[i - 2]))
    return dp[n]


print((main()))

-class struct: -    def __init__(self, a, b): -        self.a = a -        self.b = b +import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, random, time + +sys.setrecursionlimit(10**7) +inf = 10**20 +mod = 10**9 + 7 -n = int(eval(input())) -l = list(map(int, input().split())) -l2 = [struct(0, 0) for _ in range(n)] -l2[0].a = l[0] -l2[1].a = l[1] -l2[1].b = abs(l[0] - l[1]) -i = 2 -for x in l[2:]: -    l2[i].a = x -    l2[i].b = min( -        abs(l2[i - 2].a - x) + l2[i - 2].b, abs(l2[i - 1].a - x) + l2[i - 1].b -    ) -    i += 1 -print((l2[-1].b)) +def LI(): +    return list(map(int, input().split())) + + +def I(): +    return int(eval(input())) + + +def LS(): +    return input().split() + + +def S(): +    return eval(input()) + + +def main(): +    n = I() +    l = LI() +    dp = [0] * 100010 +    dp[1] = 0 +    dp[2] = abs(l[0] - l[1]) +    for i in range(2, n): +        dp[i + 1] = min(dp[i] + abs(l[i] - l[i - 1]), dp[i - 1] + abs(l[i] - l[i - 2])) +    return dp[n] + + +print((main()))