import sys

read = sys.stdin.read

readline = sys.stdin.readline

readlines = sys.stdin.readlines



N = int(readline())

A = tuple(map(int, read().split()))



if N == 2:

    print((A[1] - A[0]))

    exit()



dp = [10 ** 10] * N

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

dp[2] = abs(A[2] - A[0])



for i in range(3, N):

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



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

read = sys.stdin.read

readline = sys.stdin.readline

readlines = sys.stdin.readlines





def main():

    N = int(readline())

    A = tuple(map(int, read().split()))



    if N == 2:

        print((A[1] - A[0]))

        exit()



    dp = [10 ** 10] * N

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

    dp[2] = abs(A[2] - A[0])



    for i in range(3, N):

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



    print((dp[-1]))





if __name__ == '__main__':

    main()
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
N = int(readline())
A = tuple(map(int, read().split()))
if N == 2:
    print((A[1] - A[0]))
    exit()
dp = [10**10] * N
dp[1] = abs(A[1] - A[0])
dp[2] = abs(A[2] - A[0])
for i in range(3, N):
    dp[i] = min(dp[i - 1] + abs(A[i] - A[i - 1]), dp[i - 2] + abs(A[i] - A[i - 2]))
print((dp[-1]))

import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines


def main():
    N = int(readline())
    A = tuple(map(int, read().split()))
    if N == 2:
        print((A[1] - A[0]))
        exit()
    dp = [10**10] * N
    dp[1] = abs(A[1] - A[0])
    dp[2] = abs(A[2] - A[0])
    for i in range(3, N):
        dp[i] = min(dp[i - 1] + abs(A[i] - A[i - 1]), dp[i - 2] + abs(A[i] - A[i - 2]))
    print((dp[-1]))


if __name__ == "__main__":
    main()

-N = int(readline()) -A = tuple(map(int, read().split())) -if N == 2: -    print((A[1] - A[0])) -    exit() -dp = [10**10] * N -dp[1] = abs(A[1] - A[0]) -dp[2] = abs(A[2] - A[0]) -for i in range(3, N): -    dp[i] = min(dp[i - 1] + abs(A[i] - A[i - 1]), dp[i - 2] + abs(A[i] - A[i - 2])) -print((dp[-1])) + + +def main(): +    N = int(readline()) +    A = tuple(map(int, read().split())) +    if N == 2: +        print((A[1] - A[0])) +        exit() +    dp = [10**10] * N +    dp[1] = abs(A[1] - A[0]) +    dp[2] = abs(A[2] - A[0]) +    for i in range(3, N): +        dp[i] = min(dp[i - 1] + abs(A[i] - A[i - 1]), dp[i - 2] + abs(A[i] - A[i - 2])) +    print((dp[-1])) + + +if __name__ == "__main__": +    main()