nums = int(eval(input()))

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

dp = [0 for i in range(nums)]

for i in range(1,nums):

    dp[i] = float("inf")

jump_min = 0

for i in range(1,nums):

    for x in range(1,3):

        jump = i-x

        if i-x < 0: continue

        jump = dp[i-x] + abs(ary[i-x] - ary[i])

        if jump < dp[i]:

            dp[i] = jump

print((dp[nums-1]))
n = int(eval(input()))

dp = [float("Inf") for _ in range(n)]

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

dp[0] = 0

for i in range(n-1):

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

    if  i +2 <= n-1:

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

print((dp[n-1]))
nums = int(eval(input()))
ary = list(map(int, input().split()))
dp = [0 for i in range(nums)]
for i in range(1, nums):
    dp[i] = float("inf")
jump_min = 0
for i in range(1, nums):
    for x in range(1, 3):
        jump = i - x
        if i - x < 0:
            continue
        jump = dp[i - x] + abs(ary[i - x] - ary[i])
        if jump < dp[i]:
            dp[i] = jump
print((dp[nums - 1]))

n = int(eval(input()))
dp = [float("Inf") for _ in range(n)]
ary = list(map(int, input().split()))
dp[0] = 0
for i in range(n - 1):
    dp[i + 1] = min(dp[i + 1], abs(ary[i] - ary[i + 1]) + dp[i])
    if i + 2 <= n - 1:
        dp[i + 2] = min(dp[i + 2], abs(ary[i] - ary[i + 2]) + dp[i])
print((dp[n - 1]))

-nums = int(eval(input())) +n = int(eval(input())) +dp = [float("Inf") for _ in range(n)] -dp = [0 for i in range(nums)] -for i in range(1, nums): -    dp[i] = float("inf") -jump_min = 0 -for i in range(1, nums): -    for x in range(1, 3): -        jump = i - x -        if i - x < 0: -            continue -        jump = dp[i - x] + abs(ary[i - x] - ary[i]) -        if jump < dp[i]: -            dp[i] = jump -print((dp[nums - 1])) +dp[0] = 0 +for i in range(n - 1): +    dp[i + 1] = min(dp[i + 1], abs(ary[i] - ary[i + 1]) + dp[i]) +    if i + 2 <= n - 1: +        dp[i + 2] = min(dp[i + 2], abs(ary[i] - ary[i + 2]) + dp[i]) +print((dp[n - 1]))