import sys

sys.setrecursionlimit(10**7)



N = int(eval(input()))

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



cost = [0, abs(h[1]-h[0])]

def dp(i):

  if i >= len(cost):

    cost.append(min(dp(i-1)+abs(h[i]-h[i-1]), dp(i-2)+abs(h[i]-h[i-2])))

  return cost[i]



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

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



def dp(n):

  a, b = 0, abs(h[1]-h[0])

  if n == 0:

    return a

  for i in range(2, n+1):

    a, b = b, min(a+abs(h[i]-h[i-2]), b+abs(h[i]-h[i-1]))

  return b

 

print((dp(N-1)))
import sys

sys.setrecursionlimit(10**7)
N = int(eval(input()))
h = list(map(int, input().split()))
cost = [0, abs(h[1] - h[0])]


def dp(i):
    if i >= len(cost):
        cost.append(
            min(dp(i - 1) + abs(h[i] - h[i - 1]), dp(i - 2) + abs(h[i] - h[i - 2]))
        )
    return cost[i]


print((dp(N - 1)))

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


def dp(n):
    a, b = 0, abs(h[1] - h[0])
    if n == 0:
        return a
    for i in range(2, n + 1):
        a, b = b, min(a + abs(h[i] - h[i - 2]), b + abs(h[i] - h[i - 1]))
    return b


print((dp(N - 1)))

-import sys - -sys.setrecursionlimit(10**7) -cost = [0, abs(h[1] - h[0])] -def dp(i): -    if i >= len(cost): -        cost.append( -            min(dp(i - 1) + abs(h[i] - h[i - 1]), dp(i - 2) + abs(h[i] - h[i - 2])) -        ) -    return cost[i] +def dp(n): +    a, b = 0, abs(h[1] - h[0]) +    if n == 0: +        return a +    for i in range(2, n + 1): +        a, b = b, min(a + abs(h[i] - h[i - 2]), b + abs(h[i] - h[i - 1])) +    return b