import sys

stdin = sys.stdin

 

sys.setrecursionlimit(10**5) 

 

def li(): return list(map(int, stdin.readline().split()))

def li_(): return [int(x)-1 for x in stdin.readline().split()]

def lf(): return list(map(float, stdin.readline().split()))

def ls(): return stdin.readline().split()

def ns(): return stdin.readline().rstrip()

def lc(): return list(ns())

def ni(): return int(stdin.readline())

def nf(): return float(stdin.readline())



n = ni()

h = list(li())



cost = [float("inf")]*(n)

cost[0] = 0



for i in range(n-1):

    if i == n-2:

        cost[i+1] = min(cost[i+1],

                        cost[i] + abs(h[i+1]-h[i]))

        

    else:

        cost[i+1] = min(cost[i+1],

                        cost[i] + abs(h[i+1]-h[i]))

        cost[i+2] = min(cost[i+2],

                        cost[i] + abs(h[i+2]-h[i]))

        

print((cost[-1]))

        
import sys

stdin = sys.stdin

 

sys.setrecursionlimit(10**5) 

 

def li(): return list(map(int, stdin.readline().split()))

def li_(): return [int(x)-1 for x in stdin.readline().split()]

def lf(): return list(map(float, stdin.readline().split()))

def ls(): return stdin.readline().split()

def ns(): return stdin.readline().rstrip()

def lc(): return list(ns())

def ni(): return int(stdin.readline())

def nf(): return float(stdin.readline())



n = ni()

h = list(li())



dp = [0]*n

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

for i in range(1,n-1):

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

                  dp[i] + abs(h[i+1]-h[i]))

    

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

stdin = sys.stdin
sys.setrecursionlimit(10**5)


def li():
    return list(map(int, stdin.readline().split()))


def li_():
    return [int(x) - 1 for x in stdin.readline().split()]


def lf():
    return list(map(float, stdin.readline().split()))


def ls():
    return stdin.readline().split()


def ns():
    return stdin.readline().rstrip()


def lc():
    return list(ns())


def ni():
    return int(stdin.readline())


def nf():
    return float(stdin.readline())


n = ni()
h = list(li())
cost = [float("inf")] * (n)
cost[0] = 0
for i in range(n - 1):
    if i == n - 2:
        cost[i + 1] = min(cost[i + 1], cost[i] + abs(h[i + 1] - h[i]))
    else:
        cost[i + 1] = min(cost[i + 1], cost[i] + abs(h[i + 1] - h[i]))
        cost[i + 2] = min(cost[i + 2], cost[i] + abs(h[i + 2] - h[i]))
print((cost[-1]))

import sys

stdin = sys.stdin
sys.setrecursionlimit(10**5)


def li():
    return list(map(int, stdin.readline().split()))


def li_():
    return [int(x) - 1 for x in stdin.readline().split()]


def lf():
    return list(map(float, stdin.readline().split()))


def ls():
    return stdin.readline().split()


def ns():
    return stdin.readline().rstrip()


def lc():
    return list(ns())


def ni():
    return int(stdin.readline())


def nf():
    return float(stdin.readline())


n = ni()
h = list(li())
dp = [0] * n
dp[1] = abs(h[1] - h[0])
for i in range(1, n - 1):
    dp[i + 1] = min(dp[i - 1] + abs(h[i + 1] - h[i - 1]), dp[i] + abs(h[i + 1] - h[i]))
print((dp[-1]))

-cost = [float("inf")] * (n) -cost[0] = 0 -for i in range(n - 1): -    if i == n - 2: -        cost[i + 1] = min(cost[i + 1], cost[i] + abs(h[i + 1] - h[i])) -    else: -        cost[i + 1] = min(cost[i + 1], cost[i] + abs(h[i + 1] - h[i])) -        cost[i + 2] = min(cost[i + 2], cost[i] + abs(h[i + 2] - h[i])) -print((cost[-1])) +dp = [0] * n +dp[1] = abs(h[1] - h[0]) +for i in range(1, n - 1): +    dp[i + 1] = min(dp[i - 1] + abs(h[i + 1] - h[i - 1]), dp[i] + abs(h[i + 1] - h[i])) +print((dp[-1]))