from functools import lru_cache

import sys



iMaxStackSize = 5000000

sys.setrecursionlimit(iMaxStackSize)

n = int(eval(input()))

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



@lru_cache(None)

def solve(i):

    if i == n - 1:

        return 0

    if i + 2 >= len(heights):

        return abs(heights[i + 1] - heights[i])

    option1 = abs(heights[i] - heights[i + 1])

    option1 += solve(i + 1)

    option2 = abs(heights[i] - heights[i + 2])

    option2 += solve(i + 2)

    return min(option1, option2)



print((solve(0)))

n = int(eval(input()))

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



dp = [float("inf")] * n

dp[0] = 0

for i in range(1, n):

    if i - 2 >= 0:

        val1 = abs(heights[i] - heights[i - 1]) + dp[i - 1]

        val2 = abs(heights[i] - heights[i - 2]) + dp[i - 2]

        dp[i] = min(val1, val2)

    else:

        dp[i] = abs(heights[i] - heights[i - 1]) + dp[i - 1]

print((dp[-1]))
from functools import lru_cache
import sys

iMaxStackSize = 5000000
sys.setrecursionlimit(iMaxStackSize)
n = int(eval(input()))
heights = [int(x) for x in input().split()]


@lru_cache(None)
def solve(i):
    if i == n - 1:
        return 0
    if i + 2 >= len(heights):
        return abs(heights[i + 1] - heights[i])
    option1 = abs(heights[i] - heights[i + 1])
    option1 += solve(i + 1)
    option2 = abs(heights[i] - heights[i + 2])
    option2 += solve(i + 2)
    return min(option1, option2)


print((solve(0)))

n = int(eval(input()))
heights = [int(x) for x in input().split()]
dp = [float("inf")] * n
dp[0] = 0
for i in range(1, n):
    if i - 2 >= 0:
        val1 = abs(heights[i] - heights[i - 1]) + dp[i - 1]
        val2 = abs(heights[i] - heights[i - 2]) + dp[i - 2]
        dp[i] = min(val1, val2)
    else:
        dp[i] = abs(heights[i] - heights[i - 1]) + dp[i - 1]
print((dp[-1]))

-from functools import lru_cache -import sys - -iMaxStackSize = 5000000 -sys.setrecursionlimit(iMaxStackSize) - - -@lru_cache(None) -def solve(i): -    if i == n - 1: -        return 0 -    if i + 2 >= len(heights): -        return abs(heights[i + 1] - heights[i]) -    option1 = abs(heights[i] - heights[i + 1]) -    option1 += solve(i + 1) -    option2 = abs(heights[i] - heights[i + 2]) -    option2 += solve(i + 2) -    return min(option1, option2) - - -print((solve(0))) +dp = [float("inf")] * n +dp[0] = 0 +for i in range(1, n): +    if i - 2 >= 0: +        val1 = abs(heights[i] - heights[i - 1]) + dp[i - 1] +        val2 = abs(heights[i] - heights[i - 2]) + dp[i - 2] +        dp[i] = min(val1, val2) +    else: +        dp[i] = abs(heights[i] - heights[i - 1]) + dp[i - 1] +print((dp[-1]))