import sys

sys.setrecursionlimit(500*500)



N =int(eval(input()))

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

H.append(0)

#総数Nで、N番目の添字はN-1



#メモ化再帰

#今の場所からゴールまでの最小コストを出す

now = 0

memo = [-1]*N

def func(n,memo):

  if n >= N:

    return 99999999

  if n == N-1:

    memo[N-1] = 0

    return 0

  else:

    if memo[n] != -1:

      return memo[n]

    else:

      min_later = min(func(n+1,memo)+abs(H[n+1]-H[n]), func(n+2,memo)+abs(H[n+2]-H[n]))

      memo[n] = min_later

    return min_later



print((func(now,memo)))
import sys

sys.setrecursionlimit(500*500)



N =int(eval(input())) 

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

  

memo = [-1]*N 

def func(n,memo): 

  if n == 0: 

    memo[0] = 0 

    return memo[n] 

  elif n == 1: 

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

    return memo[n] 

  else: 

    if memo[n] != -1: 

      return memo[n] 

    else: 

      min_c = min(func(n-1,memo)+abs(H[n]-H[n-1]), func(n-2,memo)+abs(H[n]-H[n-2])) 

      memo[n] = min_c 

    return min_c 

  

print((func(N-1,memo))) 
import sys

sys.setrecursionlimit(500 * 500)
N = int(eval(input()))
H = list(map(int, input().split()))
H.append(0)
# 総数Nで、N番目の添字はN-1
# メモ化再帰
# 今の場所からゴールまでの最小コストを出す
now = 0
memo = [-1] * N


def func(n, memo):
    if n >= N:
        return 99999999
    if n == N - 1:
        memo[N - 1] = 0
        return 0
    else:
        if memo[n] != -1:
            return memo[n]
        else:
            min_later = min(
                func(n + 1, memo) + abs(H[n + 1] - H[n]),
                func(n + 2, memo) + abs(H[n + 2] - H[n]),
            )
            memo[n] = min_later
        return min_later


print((func(now, memo)))

import sys

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


def func(n, memo):
    if n == 0:
        memo[0] = 0
        return memo[n]
    elif n == 1:
        memo[1] = abs(H[1] - H[0])
        return memo[n]
    else:
        if memo[n] != -1:
            return memo[n]
        else:
            min_c = min(
                func(n - 1, memo) + abs(H[n] - H[n - 1]),
                func(n - 2, memo) + abs(H[n] - H[n - 2]),
            )
            memo[n] = min_c
        return min_c


print((func(N - 1, memo)))

-H.append(0) -# 総数Nで、N番目の添字はN-1 -# メモ化再帰 -# 今の場所からゴールまでの最小コストを出す -now = 0 -    if n >= N: -        return 99999999 -    if n == N - 1: -        memo[N - 1] = 0 -        return 0 +    if n == 0: +        memo[0] = 0 +        return memo[n] +    elif n == 1: +        memo[1] = abs(H[1] - H[0]) +        return memo[n] -            min_later = min( -                func(n + 1, memo) + abs(H[n + 1] - H[n]), -                func(n + 2, memo) + abs(H[n + 2] - H[n]), +            min_c = min( +                func(n - 1, memo) + abs(H[n] - H[n - 1]), +                func(n - 2, memo) + abs(H[n] - H[n - 2]), -            memo[n] = min_later -        return min_later +            memo[n] = min_c +        return min_c -print((func(now, memo))) +print((func(N - 1, memo)))