import sys

sys.setrecursionlimit(10**5-10)



N = int(eval(input()))

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



memo = [-1]*N



def func(i):

  # メモのロード

  if memo[i]!=-1:

    return memo[i]

  # 初期値の部分

  if i==0:

    return 0

  elif i==1: 

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

  # 二択の部分

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

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

  memo[i] = min(a,b) # メモのセーブ

  return memo[i]



print((func(N-1)))

N = int(eval(input()))

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



dp = [-1]*N

dp[0] = 0

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

for i in range(2,N):

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

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

  dp[i] = min(a,b)

print((dp[N-1]))

import sys

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


def func(i):
    # メモのロード
    if memo[i] != -1:
        return memo[i]
    # 初期値の部分
    if i == 0:
        return 0
    elif i == 1:
        return abs(h[1] - h[0])
    # 二択の部分
    a = func(i - 1) + abs(h[i] - h[i - 1])
    b = func(i - 2) + abs(h[i] - h[i - 2])
    memo[i] = min(a, b)  # メモのセーブ
    return memo[i]


print((func(N - 1)))

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

-import sys - -sys.setrecursionlimit(10**5 - 10) -memo = [-1] * N - - -def func(i): -    # メモのロード -    if memo[i] != -1: -        return memo[i] -    # 初期値の部分 -    if i == 0: -        return 0 -    elif i == 1: -        return abs(h[1] - h[0]) -    # 二択の部分 -    a = func(i - 1) + abs(h[i] - h[i - 1]) -    b = func(i - 2) + abs(h[i] - h[i - 2]) -    memo[i] = min(a, b)  # メモのセーブ -    return memo[i] - - -print((func(N - 1))) +dp = [-1] * N +dp[0] = 0 +dp[1] = abs(h[1] - h[0]) +for i in range(2, N): +    a = dp[i - 1] + abs(h[i] - h[i - 1]) +    b = dp[i - 2] + abs(h[i] - h[i - 2]) +    dp[i] = min(a, b) +print((dp[N - 1]))