import sys

sys.setrecursionlimit(200000)

 

n = int(eval(input()))

 

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

 

d = {}

 

def dp(p):

  if p in d:

    return d[p]

  if p == n-1:

    return 0

  if p < n-2:

    m = min(dp(p+1)+abs(h[p]-h[p+1]), dp(p+2)+abs(h[p]-h[p+2]))

    d[p] = m

    return m

  if p == n-2:

    return dp(p+1)+abs(h[p]-h[p+1])



print((dp(0)))

n = int(eval(input()))

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



dp = [0] * n

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

for i in range(2, n):

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



print((dp[-1]))

 
import sys

sys.setrecursionlimit(200000)
n = int(eval(input()))
h = [int(i) for i in input().split()]
d = {}


def dp(p):
    if p in d:
        return d[p]
    if p == n - 1:
        return 0
    if p < n - 2:
        m = min(dp(p + 1) + abs(h[p] - h[p + 1]), dp(p + 2) + abs(h[p] - h[p + 2]))
        d[p] = m
        return m
    if p == n - 2:
        return dp(p + 1) + abs(h[p] - h[p + 1])


print((dp(0)))

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

-import sys - -sys.setrecursionlimit(200000) -h = [int(i) for i in input().split()] -d = {} - - -def dp(p): -    if p in d: -        return d[p] -    if p == n - 1: -        return 0 -    if p < n - 2: -        m = min(dp(p + 1) + abs(h[p] - h[p + 1]), dp(p + 2) + abs(h[p] - h[p + 2])) -        d[p] = m -        return m -    if p == n - 2: -        return dp(p + 1) + abs(h[p] - h[p + 1]) - - -print((dp(0))) +h = list(map(int, input().split())) +dp = [0] * n +dp[1] = abs(h[1] - h[0]) +for i in range(2, n): +    dp[i] = min(dp[i - 2] + abs(h[i] - h[i - 2]), dp[i - 1] + abs(h[i] - h[i - 1])) +print((dp[-1]))