import sys

from functools import lru_cache



sys.setrecursionlimit(10**6)



INF = sys.maxsize



N = int(input().strip())

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



@lru_cache()

def solve(i):

  if i >= N - 1:

    return 0

  return min(    

    solve(i + 1) + abs(h[i] - h[i + 1]) if i + 1 < N else INF,

    solve(i + 2) + abs(h[i] - h[i + 2]) if i + 2 < N else INF

  )

  

print((solve(0)))
import sys



INF = sys.maxsize



N = int(input().strip())

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



memo = [INF] * N



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

  if i == N -1:

    memo[i] = 0

  else:

    memo[i] = min(

      memo[i + 1] + abs(h[i] - h[i + 1]) if i + 1 < N else INF,

      memo[i + 2] + abs(h[i] - h[i + 2]) if i + 2 < N else INF                        

    )

  

print((memo[0]))
import sys
from functools import lru_cache

sys.setrecursionlimit(10**6)
INF = sys.maxsize
N = int(input().strip())
h = [int(x) for x in input().split()]


@lru_cache()
def solve(i):
    if i >= N - 1:
        return 0
    return min(
        solve(i + 1) + abs(h[i] - h[i + 1]) if i + 1 < N else INF,
        solve(i + 2) + abs(h[i] - h[i + 2]) if i + 2 < N else INF,
    )


print((solve(0)))

import sys

INF = sys.maxsize
N = int(input().strip())
h = [int(x) for x in input().split()]
memo = [INF] * N
for i in range(N - 1, -1, -1):
    if i == N - 1:
        memo[i] = 0
    else:
        memo[i] = min(
            memo[i + 1] + abs(h[i] - h[i + 1]) if i + 1 < N else INF,
            memo[i + 2] + abs(h[i] - h[i + 2]) if i + 2 < N else INF,
        )
print((memo[0]))

-from functools import lru_cache -sys.setrecursionlimit(10**6) - - -@lru_cache() -def solve(i): -    if i >= N - 1: -        return 0 -    return min( -        solve(i + 1) + abs(h[i] - h[i + 1]) if i + 1 < N else INF, -        solve(i + 2) + abs(h[i] - h[i + 2]) if i + 2 < N else INF, -    ) - - -print((solve(0))) +memo = [INF] * N +for i in range(N - 1, -1, -1): +    if i == N - 1: +        memo[i] = 0 +    else: +        memo[i] = min( +            memo[i + 1] + abs(h[i] - h[i + 1]) if i + 1 < N else INF, +            memo[i + 2] + abs(h[i] - h[i + 2]) if i + 2 < N else INF, +        ) +print((memo[0]))