import sys

sys.setrecursionlimit(10 ** 7)



def solve(index: int, dp: list, footing: list) -> int:

    if dp[index] != -1:

        return dp[index]



    if index == 0:

        return 0

    elif index == 1:

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



    tmp = min(solve(index-1, dp, footing)+abs(footing[index]-footing[index-1]), solve(index-2, dp, footing)+abs(footing[index]-footing[index-2]))

    #print(f'{tmp=}')

    dp[index] = tmp

    return tmp



N = int(eval(input()))

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



dp = [-1] * N



ans = solve(N-1, dp, footing)



print(ans)


N = int(eval(input()))

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



dp = [10 ** 10] * N

dp[0] = 0



# give

for i in range(N-1):

    if dp[i+1] > dp[i] + abs(footing[i+1] - footing[i]):

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



    if i < N-2:

        if dp[i+2] > dp[i] + abs(footing[i+2] - footing[i]):

            dp[i+2] = dp[i] + abs(footing[i+2] - footing[i])



print((dp[N-1]))
import sys

sys.setrecursionlimit(10**7)


def solve(index: int, dp: list, footing: list) -> int:
    if dp[index] != -1:
        return dp[index]
    if index == 0:
        return 0
    elif index == 1:
        return abs(footing[1] - footing[0])
    tmp = min(
        solve(index - 1, dp, footing) + abs(footing[index] - footing[index - 1]),
        solve(index - 2, dp, footing) + abs(footing[index] - footing[index - 2]),
    )
    # print(f'{tmp=}')
    dp[index] = tmp
    return tmp


N = int(eval(input()))
footing = list(map(int, input().split()))
dp = [-1] * N
ans = solve(N - 1, dp, footing)
print(ans)

N = int(eval(input()))
footing = list(map(int, input().split()))
dp = [10**10] * N
dp[0] = 0
# give
for i in range(N - 1):
    if dp[i + 1] > dp[i] + abs(footing[i + 1] - footing[i]):
        dp[i + 1] = dp[i] + abs(footing[i + 1] - footing[i])
    if i < N - 2:
        if dp[i + 2] > dp[i] + abs(footing[i + 2] - footing[i]):
            dp[i + 2] = dp[i] + abs(footing[i + 2] - footing[i])
print((dp[N - 1]))

-import sys - -sys.setrecursionlimit(10**7) - - -def solve(index: int, dp: list, footing: list) -> int: -    if dp[index] != -1: -        return dp[index] -    if index == 0: -        return 0 -    elif index == 1: -        return abs(footing[1] - footing[0]) -    tmp = min( -        solve(index - 1, dp, footing) + abs(footing[index] - footing[index - 1]), -        solve(index - 2, dp, footing) + abs(footing[index] - footing[index - 2]), -    ) -    # print(f'{tmp=}') -    dp[index] = tmp -    return tmp - - -dp = [-1] * N -ans = solve(N - 1, dp, footing) -print(ans) +dp = [10**10] * N +dp[0] = 0 +# give +for i in range(N - 1): +    if dp[i + 1] > dp[i] + abs(footing[i + 1] - footing[i]): +        dp[i + 1] = dp[i] + abs(footing[i + 1] - footing[i]) +    if i < N - 2: +        if dp[i + 2] > dp[i] + abs(footing[i + 2] - footing[i]): +            dp[i + 2] = dp[i] + abs(footing[i + 2] - footing[i]) +print((dp[N - 1]))