import numpy as np

import sys

sys.setrecursionlimit(10**6)



N = int(eval(input()))

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



memo = np.zeros(N) - 1



def search(i):

  if i == 0:

    return 0

  elif i == 1:

    return abs(h[i] - h[i-1])

  if memo[i] != -1:

    return memo[i]

  

  c1 = search(i-1) + abs(h[i]-h[i-1])

  c2 = search(i-2) + abs(h[i]-h[i-2])

  memo[i] = min(c1,c2)

  return min(c1,c2)



print((int(search(N-1))))
import numpy as np



N = int(eval(input()))

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



memo = np.zeros(N)

memo[0] = 0

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



for i in range(2,N):

  a = memo[i-1] + abs(h[i] - h[i-1])

  b = memo[i-2] + abs(h[i] - h[i-2])

  memo[i] = min(a,b)



print((int(memo[N-1])))
import numpy as np
import sys

sys.setrecursionlimit(10**6)
N = int(eval(input()))
h = list(map(int, input().split()))
memo = np.zeros(N) - 1


def search(i):
    if i == 0:
        return 0
    elif i == 1:
        return abs(h[i] - h[i - 1])
    if memo[i] != -1:
        return memo[i]
    c1 = search(i - 1) + abs(h[i] - h[i - 1])
    c2 = search(i - 2) + abs(h[i] - h[i - 2])
    memo[i] = min(c1, c2)
    return min(c1, c2)


print((int(search(N - 1))))

import numpy as np

N = int(eval(input()))
h = list(map(int, input().split()))
memo = np.zeros(N)
memo[0] = 0
memo[1] = abs(h[0] - h[1])
for i in range(2, N):
    a = memo[i - 1] + abs(h[i] - h[i - 1])
    b = memo[i - 2] + abs(h[i] - h[i - 2])
    memo[i] = min(a, b)
print((int(memo[N - 1])))

-import sys -sys.setrecursionlimit(10**6) -memo = np.zeros(N) - 1 - - -def search(i): -    if i == 0: -        return 0 -    elif i == 1: -        return abs(h[i] - h[i - 1]) -    if memo[i] != -1: -        return memo[i] -    c1 = search(i - 1) + abs(h[i] - h[i - 1]) -    c2 = search(i - 2) + abs(h[i] - h[i - 2]) -    memo[i] = min(c1, c2) -    return min(c1, c2) - - -print((int(search(N - 1)))) +memo = np.zeros(N) +memo[0] = 0 +memo[1] = abs(h[0] - h[1]) +for i in range(2, N): +    a = memo[i - 1] + abs(h[i] - h[i - 1]) +    b = memo[i - 2] + abs(h[i] - h[i - 2]) +    memo[i] = min(a, b) +print((int(memo[N - 1])))