import sys

sys.setrecursionlimit(20000000)

n=int(eval(input()))

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

memory={}

def cost(place):

    if place in memory:

        return memory[place]

    if place==n-1:

        return 0

    if place==n-2:

        return abs(h[n-2]-h[n-1])

    if place<=n-3:

        a=abs(h[place]-h[place+2])+cost(place+2)

        b=abs(h[place]-h[place+1])+cost(place+1)

        x=min(a,b)

        memory[place]=x

        return x

print((cost(0)))

n=int(eval(input()))

h=[int(i) for i in input().split()]

p0=0

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

for i in range(2,n):

    p2=min(abs(h[i]-h[i-2])+p0,abs(h[i]-h[i-1])+p1)

    p0,p1=p1,p2

print(p1)
import sys

sys.setrecursionlimit(20000000)
n = int(eval(input()))
h = list(map(int, input().split()))
memory = {}


def cost(place):
    if place in memory:
        return memory[place]
    if place == n - 1:
        return 0
    if place == n - 2:
        return abs(h[n - 2] - h[n - 1])
    if place <= n - 3:
        a = abs(h[place] - h[place + 2]) + cost(place + 2)
        b = abs(h[place] - h[place + 1]) + cost(place + 1)
        x = min(a, b)
        memory[place] = x
        return x


print((cost(0)))

n = int(eval(input()))
h = [int(i) for i in input().split()]
p0 = 0
p1 = abs(h[1] - h[0])
for i in range(2, n):
    p2 = min(abs(h[i] - h[i - 2]) + p0, abs(h[i] - h[i - 1]) + p1)
    p0, p1 = p1, p2
print(p1)

-import sys - -sys.setrecursionlimit(20000000) -h = list(map(int, input().split())) -memory = {} - - -def cost(place): -    if place in memory: -        return memory[place] -    if place == n - 1: -        return 0 -    if place == n - 2: -        return abs(h[n - 2] - h[n - 1]) -    if place <= n - 3: -        a = abs(h[place] - h[place + 2]) + cost(place + 2) -        b = abs(h[place] - h[place + 1]) + cost(place + 1) -        x = min(a, b) -        memory[place] = x -        return x - - -print((cost(0))) +h = [int(i) for i in input().split()] +p0 = 0 +p1 = abs(h[1] - h[0]) +for i in range(2, n): +    p2 = min(abs(h[i] - h[i - 2]) + p0, abs(h[i] - h[i - 1]) + p1) +    p0, p1 = p1, p2 +print(p1)