size = int(eval(input()))

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

dp = [0]*(size)

dp[0] = 0

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

for i in range(2,size):

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



print((dp[size-1]))

n = int(eval(input()))

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

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

sum = 0

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

for i in range(2, len(arr)):

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

print((dp[-1]))

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

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

-size = int(eval(input())) +n = int(eval(input())) -dp = [0] * (size) -dp[0] = 0 +dp = [0 for i in range(n)] +sum = 0 -for i in range(2, size): +for i in range(2, len(arr)): -        dp[i - 1] + abs(arr[i - 1] - arr[i]), dp[i - 2] + abs(arr[i - 2] - arr[i]) +        dp[i - 1] + abs(arr[i] - arr[i - 1]), dp[i - 2] + abs(arr[i] - arr[i - 2]) -print((dp[size - 1])) +print((dp[-1]))