#!/usr/bin/env python3



n = int(eval(input()))



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



twojump = 0

onejump = abs(harr[1] - harr[0])

ans = onejump



for i in range(2, n):

    ans = min(abs(harr[i]-harr[i-1])+onejump, abs(harr[i]-harr[i-2])+twojump)

    twojump = onejump

    onejump = ans



print(ans)

#!/usr/bin/env python3



n = int(eval(input()))



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



dp = [10**10]*n



dp[0] = 0



for i in range(0, n):

    for j in range(1, 3):

        if i+j < n:

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



print((dp[n-1]))

#!/usr/bin/env python3
n = int(eval(input()))
harr = [int(i) for i in input().split(" ")]
twojump = 0
onejump = abs(harr[1] - harr[0])
ans = onejump
for i in range(2, n):
    ans = min(
        abs(harr[i] - harr[i - 1]) + onejump, abs(harr[i] - harr[i - 2]) + twojump
    )
    twojump = onejump
    onejump = ans
print(ans)

#!/usr/bin/env python3
n = int(eval(input()))
arr = [int(i) for i in input().split(" ")]
dp = [10**10] * n
dp[0] = 0
for i in range(0, n):
    for j in range(1, 3):
        if i + j < n:
            dp[i + j] = min(dp[i + j], dp[i] + abs(arr[i + j] - arr[i]))
print((dp[n - 1]))

-harr = [int(i) for i in input().split(" ")] -twojump = 0 -onejump = abs(harr[1] - harr[0]) -ans = onejump -for i in range(2, n): -    ans = min( -        abs(harr[i] - harr[i - 1]) + onejump, abs(harr[i] - harr[i - 2]) + twojump -    ) -    twojump = onejump -    onejump = ans -print(ans) +arr = [int(i) for i in input().split(" ")] +dp = [10**10] * n +dp[0] = 0 +for i in range(0, n): +    for j in range(1, 3): +        if i + j < n: +            dp[i + j] = min(dp[i + j], dp[i] + abs(arr[i + j] - arr[i])) +print((dp[n - 1]))