import sys

sys.setrecursionlimit(10**6)



N = int(eval(input()))

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



memo = [-1]*N



def calc_cost(i):

  if memo[i] != -1:

    return memo[i]

  

  if i == 0:

    return 0

  elif i == 1:

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

  

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

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

  

  memo[i] = min(a,b)

  return(memo[i])



print((calc_cost(N-1)))
N = int(eval(input()))

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



memo = [0]*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((memo[N-1]))
import sys

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


def calc_cost(i):
    if memo[i] != -1:
        return memo[i]
    if i == 0:
        return 0
    elif i == 1:
        return abs(h[0] - h[1])
    a = calc_cost(i - 1) + abs(h[i] - h[i - 1])
    b = calc_cost(i - 2) + abs(h[i] - h[i - 2])
    memo[i] = min(a, b)
    return memo[i]


print((calc_cost(N - 1)))

N = int(eval(input()))
h = list(map(int, input().split()))
memo = [0] * 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((memo[N - 1]))

-import sys - -sys.setrecursionlimit(10**6) -memo = [-1] * N - - -def calc_cost(i): -    if memo[i] != -1: -        return memo[i] -    if i == 0: -        return 0 -    elif i == 1: -        return abs(h[0] - h[1]) -    a = calc_cost(i - 1) + abs(h[i] - h[i - 1]) -    b = calc_cost(i - 2) + abs(h[i] - h[i - 2]) +memo = [0] * 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]) -    return memo[i] - - -print((calc_cost(N - 1))) +print((memo[N - 1]))